Skip to content

Commit 66f170e

Browse files
author
Aamod Pisat
committed
Added es6-promise polyfill in browsers.
.spread() promise function
1 parent e54a09e commit 66f170e

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

src/runtime/node/http.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,22 @@ import fetch from 'isomorphic-fetch';
33

44
ES6Promise.polyfill();
55

6+
/**
7+
* @method spread
8+
* @description return the promise with the arguments.
9+
* @example
10+
* blogQuery.find().spread()
11+
*/
12+
function spread() {
13+
if (Promise.prototype.spread) return;
14+
Promise.prototype.spread = function (fn) {
15+
return this.then(function (args) {
16+
return fn.apply(fn, args);
17+
});
18+
};
19+
}
20+
if (typeof Promise !== 'undefined') {
21+
spread();
22+
}
23+
624
export default fetch;

src/runtime/react-native/http.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@ import ES6Promise from 'es6-promise';
22
import fetch from 'isomorphic-fetch';
33

44
ES6Promise.polyfill();
5-
5+
/**
6+
* @method spread
7+
* @description return the promise with the arguments.
8+
* @example
9+
* blogQuery.find().spread()
10+
*/
11+
function spread() {
12+
if (Promise.prototype.spread) return;
13+
Promise.prototype.spread = function (fn) {
14+
return this.then(function (args) {
15+
return fn.apply(fn, args);
16+
});
17+
};
18+
}
19+
if (typeof Promise !== 'undefined') {
20+
spread();
21+
}
622
export default fetch;
723

src/runtime/web/http.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,21 @@ import ES6Promise from 'es6-promise';
22
import fetch from 'isomorphic-fetch';
33

44
ES6Promise.polyfill();
5-
5+
/**
6+
* @method spread
7+
* @description return the promise with the arguments.
8+
* @example
9+
* blogQuery.find().spread()
10+
*/
11+
function spread() {
12+
if (Promise.prototype.spread) return;
13+
Promise.prototype.spread = function (fn) {
14+
return this.then(function (args) {
15+
return fn.apply(fn, args);
16+
});
17+
};
18+
}
19+
if (typeof Promise !== 'undefined') {
20+
spread();
21+
}
622
export default fetch;

0 commit comments

Comments
 (0)