mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(bower) promise-polyfil v6.0.0
This commit is contained in:
parent
b23a230e4d
commit
caa6bd61cd
8 changed files with 139 additions and 37 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "promise-polyfill",
|
||||
"version": "5.2.0",
|
||||
"version": "6.0.0",
|
||||
"homepage": "https://github.com/taylorhakes/promise-polyfill",
|
||||
"authors": [
|
||||
"Taylor Hakes"
|
||||
|
|
@ -25,14 +25,14 @@
|
|||
"test",
|
||||
"tests"
|
||||
],
|
||||
"_release": "5.2.0",
|
||||
"_release": "6.0.0",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "5.2.0",
|
||||
"commit": "6c9f7130960756ab4f619e86a7db1b3725bc3162"
|
||||
"tag": "6.0.0",
|
||||
"commit": "33dbcad07b762540f0f743f917be9bc829108bae"
|
||||
},
|
||||
"_source": "https://github.com/taylorhakes/promise-polyfill.git",
|
||||
"_target": "^5.2.0",
|
||||
"_target": "^6.0.0",
|
||||
"_originalSource": "promise-polyfill",
|
||||
"_direct": true
|
||||
}
|
||||
94
modules/promise-polyfill/CHANGELOG.md
Normal file
94
modules/promise-polyfill/CHANGELOG.md
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
# Changelog
|
||||
|
||||
## 6.0.0 Deprecated `Promise._setImmediateFn` and `Promise._setUnhandledRejectionFn`
|
||||
This allows subsclassing Promise much easier
|
||||
- `Promise._setImmediateFn(<immediateFn>)` has been deprecated. Use `Promise._immediateFn = <immediateFn>;` instead.
|
||||
- `Promise._setUnhandledRejectionFn(<rejectionFn>)` has been deprecated. Use `Promise._unhandledRejectionFn = <rejectionFn>` instead.
|
||||
These functions will be removed in the next major version.
|
||||
|
||||
### 5.2.1 setTimeout to 0
|
||||
Fixed bug where setTimeout was set to 1 instead of 0 for async execution
|
||||
|
||||
### 5.2.0 Subclassing
|
||||
Allowed Subclassing. [#27](https://github.com/taylorhakes/promise-polyfill/pull/27)
|
||||
|
||||
### 5.1.0 Fixed reliance on setTimeout
|
||||
Changed possibly unhanded warnings to use asap function instead of setTimeout
|
||||
|
||||
## 5.0.0 Removed multiple params from Promise.all
|
||||
Removed non standard functionality of passing multiple params to Promise.all. You must pass an array now. You must change this code
|
||||
```js
|
||||
Promise.all(prom1, prom2, prom3);
|
||||
```
|
||||
to this
|
||||
```js
|
||||
Promise.all([prom1, prom2, prom3]);
|
||||
```
|
||||
|
||||
### 4.0.4 IE8 console.warn fix
|
||||
IE8 does not have console, unless you open the developer tools. This fix checks to makes sure console.warn is defined before calling it.
|
||||
|
||||
### 4.0.3 Fix case in bower.json
|
||||
bower.json had Promise.js instead of promise.js
|
||||
|
||||
### 4.0.2 promise.js case fix in package.json
|
||||
Fixed promise.js in package.json. It was accidently published as Promise.js
|
||||
|
||||
## 4.0.1 Unhandled Rejections and Other Fixes
|
||||
- Added unhandled rejection warnings to the console
|
||||
- Removed Grunt, jasmine and other unused code
|
||||
- Renamed Promise.js to lowercase promise.js in multiple places
|
||||
|
||||
### 3.0.1 Fixed shadowing issue on setTimeout
|
||||
New version fixing this major bug https://github.com/taylorhakes/promise-polyfill/pull/17
|
||||
|
||||
## 3.0.0 Updated setTimeout to not be affected by test mocks
|
||||
This is considered a breaking change because people may have been using this functionality. If you would like to keep version 2 functionality, set Promise._setImmediateFn on `promise-polyfill` like the code below.
|
||||
|
||||
```js
|
||||
var Promise = require('promise-polyfill');
|
||||
Promise._setImmedateFn(function(fn) {
|
||||
setTimeout(fn, 1);
|
||||
});
|
||||
```
|
||||
|
||||
### 2.1.0 Promise._setImmedateFn
|
||||
Removed dead code Promise.immedateFn and added Promise._setImmediateFn(fn);
|
||||
|
||||
### 2.0.2 Simplified Global detection
|
||||
Simplified attaching to global object
|
||||
|
||||
### 2.0.1 Webworker bugfixes
|
||||
Fixed Webworkers missing window object
|
||||
|
||||
## 2.0.0
|
||||
**Changed the following line**
|
||||
```
|
||||
module.exports = root.Promise ? root.Promise : Promise;
|
||||
```
|
||||
to
|
||||
```
|
||||
module.exports = Promise;
|
||||
```
|
||||
|
||||
This means the library will not use built-in Promise by default. This allows for more consistency.
|
||||
|
||||
You can easily add the functionality back.
|
||||
```
|
||||
var Promise = window.Promise || require('promise-polyfill');
|
||||
```
|
||||
|
||||
**Added Promise.immediateFn to allow changing the setImmedate function**
|
||||
```
|
||||
Promise.immediateFn = window.setAsap;
|
||||
```
|
||||
|
||||
### 1.1.4 Updated Promise to use correct global object in Browser and Node
|
||||
|
||||
### 1.1.3 Fixed browserify issue with `this`
|
||||
|
||||
### 1.1.2 Updated Promise.resolve to resolve with original Promise
|
||||
|
||||
### 1.1.0 Performance Improvements for Modern Browsers
|
||||
|
||||
## 1.0.1 Update README.md
|
||||
|
|
@ -49,25 +49,30 @@ prom.then(function(result) {
|
|||
});
|
||||
```
|
||||
|
||||
## Deprecations
|
||||
- `Promise._setImmediateFn(<immediateFn>)` has been deprecated. Use `Promise._immediateFn = <immediateFn>;` instead.
|
||||
- `Promise._setUnhandledRejectionFn(<rejectionFn>)` has been deprecated. Use `Promise._unhandledRejectionFn = <rejectionFn>` instead.
|
||||
These functions will be removed in the next major version.
|
||||
|
||||
## Performance
|
||||
By default promise-polyfill uses `setImmediate`, but falls back to `setTimeout` for executing asynchronously. If a browser does not support `setImmediate` (IE/Edge are the only browsers with setImmediate), you may see performance issues.
|
||||
Use a `setImmediate` polyfill to fix this issue. [setAsap](https://github.com/taylorhakes/setAsap) or [setImmediate](https://github.com/YuzuJS/setImmediate) work well.
|
||||
|
||||
If you polyfill `window.setImmediate` or use `Promise._setImmediateFn(immedateFn)` it will be used instead of `window.setTimeout`
|
||||
If you polyfill `window.setImmediate` or use `Promise._immediateFn = yourImmediateFn` it will be used instead of `window.setTimeout`
|
||||
```
|
||||
npm install setasap --save
|
||||
```
|
||||
```js
|
||||
var Promise = require('promise-polyfill');
|
||||
var setAsap = require('setasap');
|
||||
Promise._setImmediateFn(setAsap);
|
||||
Promise._immediateFn = setAsap;
|
||||
```
|
||||
|
||||
## Unhandled Rejections
|
||||
promise-polyfill will warn you about possibly unhandled rejections. It will show a console warning if a Promise is rejected, but no `.catch` is used. You can turn off this behavior by setting `Promise._setUnhandledRejectionFn(<rejectError>)`.
|
||||
If you would like to disable unhandled rejections. Use a noop like below.
|
||||
```js
|
||||
Promise._setUnhandledRejectionFn(function(rejectError) {});
|
||||
Promise._unhandledRejectionFn = function(rejectError) {};
|
||||
```
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "promise-polyfill",
|
||||
"version": "5.2.0",
|
||||
"version": "6.0.0",
|
||||
"description": "Lightweight promise polyfill. A+ compliant",
|
||||
"main": "promise.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -4,21 +4,8 @@
|
|||
// other code modifying setTimeout (like sinon.useFakeTimers())
|
||||
var setTimeoutFunc = setTimeout;
|
||||
|
||||
function noop() {
|
||||
}
|
||||
|
||||
// Use polyfill for setImmediate for performance gains
|
||||
var asap = (typeof setImmediate === 'function' && setImmediate) ||
|
||||
function (fn) {
|
||||
setTimeoutFunc(fn, 1);
|
||||
};
|
||||
|
||||
var onUnhandledRejection = function onUnhandledRejection(err) {
|
||||
if (typeof console !== 'undefined' && console) {
|
||||
console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console
|
||||
}
|
||||
};
|
||||
|
||||
function noop() {}
|
||||
|
||||
// Polyfill for Function.prototype.bind
|
||||
function bind(fn, thisArg) {
|
||||
return function () {
|
||||
|
|
@ -46,7 +33,7 @@
|
|||
return;
|
||||
}
|
||||
self._handled = true;
|
||||
asap(function () {
|
||||
Promise._immediateFn(function () {
|
||||
var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;
|
||||
if (cb === null) {
|
||||
(self._state === 1 ? resolve : reject)(deferred.promise, self._value);
|
||||
|
|
@ -95,9 +82,9 @@
|
|||
|
||||
function finale(self) {
|
||||
if (self._state === 2 && self._deferreds.length === 0) {
|
||||
asap(function() {
|
||||
Promise._immediateFn(function() {
|
||||
if (!self._handled) {
|
||||
onUnhandledRejection(self._value);
|
||||
Promise._unhandledRejectionFn(self._value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -207,19 +194,36 @@
|
|||
});
|
||||
};
|
||||
|
||||
// Use polyfill for setImmediate for performance gains
|
||||
Promise._immediateFn = (typeof setImmediate === 'function' && setImmediate) ||
|
||||
function (fn) {
|
||||
setTimeoutFunc(fn, 0);
|
||||
};
|
||||
|
||||
Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {
|
||||
if (typeof console !== 'undefined' && console) {
|
||||
console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the immediate function to execute callbacks
|
||||
* @param fn {function} Function to execute
|
||||
* @private
|
||||
* @deprecated
|
||||
*/
|
||||
Promise._setImmediateFn = function _setImmediateFn(fn) {
|
||||
asap = fn;
|
||||
Promise._immediateFn = fn;
|
||||
};
|
||||
|
||||
/**
|
||||
* Change the function to execute on unhandled rejection
|
||||
* @param {function} fn Function to execute on unhandled rejection
|
||||
* @deprecated
|
||||
*/
|
||||
Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) {
|
||||
onUnhandledRejection = fn;
|
||||
Promise._unhandledRejectionFn = fn;
|
||||
};
|
||||
|
||||
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = Promise;
|
||||
} else if (!root.Promise) {
|
||||
|
|
|
|||
2
modules/promise-polyfill/promise.min.js
vendored
2
modules/promise-polyfill/promise.min.js
vendored
|
|
@ -1 +1 @@
|
|||
!function(t){function e(){}function n(t,e){return function(){t.apply(e,arguments)}}function o(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],s(t,this)}function r(t,e){for(;3===t._state;)t=t._value;return 0===t._state?void t._deferreds.push(e):(t._handled=!0,void a(function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null===n)return void(1===t._state?i:f)(e.promise,t._value);var o;try{o=n(t._value)}catch(r){return void f(e.promise,r)}i(e.promise,o)}))}function i(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var r=e.then;if(e instanceof o)return t._state=3,t._value=e,void u(t);if("function"==typeof r)return void s(n(r,e),t)}t._state=1,t._value=e,u(t)}catch(i){f(t,i)}}function f(t,e){t._state=2,t._value=e,u(t)}function u(t){2===t._state&&0===t._deferreds.length&&a(function(){t._handled||d(t._value)});for(var e=0,n=t._deferreds.length;n>e;e++)r(t,t._deferreds[e]);t._deferreds=null}function c(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}function s(t,e){var n=!1;try{t(function(t){n||(n=!0,i(e,t))},function(t){n||(n=!0,f(e,t))})}catch(o){if(n)return;n=!0,f(e,o)}}var l=setTimeout,a="function"==typeof setImmediate&&setImmediate||function(t){l(t,1)},d=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};o.prototype["catch"]=function(t){return this.then(null,t)},o.prototype.then=function(t,n){var o=new this.constructor(e);return r(this,new c(t,n,o)),o},o.all=function(t){var e=Array.prototype.slice.call(t);return new o(function(t,n){function o(i,f){try{if(f&&("object"==typeof f||"function"==typeof f)){var u=f.then;if("function"==typeof u)return void u.call(f,function(t){o(i,t)},n)}e[i]=f,0===--r&&t(e)}catch(c){n(c)}}if(0===e.length)return t([]);for(var r=e.length,i=0;i<e.length;i++)o(i,e[i])})},o.resolve=function(t){return t&&"object"==typeof t&&t.constructor===o?t:new o(function(e){e(t)})},o.reject=function(t){return new o(function(e,n){n(t)})},o.race=function(t){return new o(function(e,n){for(var o=0,r=t.length;r>o;o++)t[o].then(e,n)})},o._setImmediateFn=function(t){a=t},o._setUnhandledRejectionFn=function(t){d=t},"undefined"!=typeof module&&module.exports?module.exports=o:t.Promise||(t.Promise=o)}(this);
|
||||
!function(t){function e(){}function n(t,e){return function(){t.apply(e,arguments)}}function o(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],s(t,this)}function r(t,e){for(;3===t._state;)t=t._value;return 0===t._state?void t._deferreds.push(e):(t._handled=!0,void a(function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null===n)return void(1===t._state?i:f)(e.promise,t._value);var o;try{o=n(t._value)}catch(r){return void f(e.promise,r)}i(e.promise,o)}))}function i(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var r=e.then;if(e instanceof o)return t._state=3,t._value=e,void u(t);if("function"==typeof r)return void s(n(r,e),t)}t._state=1,t._value=e,u(t)}catch(i){f(t,i)}}function f(t,e){t._state=2,t._value=e,u(t)}function u(t){2===t._state&&0===t._deferreds.length&&a(function(){t._handled||d(t._value)});for(var e=0,n=t._deferreds.length;n>e;e++)r(t,t._deferreds[e]);t._deferreds=null}function c(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}function s(t,e){var n=!1;try{t(function(t){n||(n=!0,i(e,t))},function(t){n||(n=!0,f(e,t))})}catch(o){if(n)return;n=!0,f(e,o)}}var l=setTimeout,a="function"==typeof setImmediate&&setImmediate||function(t){l(t,0)},d=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};o.prototype["catch"]=function(t){return this.then(null,t)},o.prototype.then=function(t,n){var o=new this.constructor(e);return r(this,new c(t,n,o)),o},o.all=function(t){var e=Array.prototype.slice.call(t);return new o(function(t,n){function o(i,f){try{if(f&&("object"==typeof f||"function"==typeof f)){var u=f.then;if("function"==typeof u)return void u.call(f,function(t){o(i,t)},n)}e[i]=f,0===--r&&t(e)}catch(c){n(c)}}if(0===e.length)return t([]);for(var r=e.length,i=0;i<e.length;i++)o(i,e[i])})},o.resolve=function(t){return t&&"object"==typeof t&&t.constructor===o?t:new o(function(e){e(t)})},o.reject=function(t){return new o(function(e,n){n(t)})},o.race=function(t){return new o(function(e,n){for(var o=0,r=t.length;r>o;o++)t[o].then(e,n)})},o._setImmediateFn=function(t){a=t},o._setUnhandledRejectionFn=function(t){d=t},"undefined"!=typeof module&&module.exports?module.exports=o:t.Promise||(t.Promise=o)}(this);
|
||||
|
|
@ -31,7 +31,6 @@
|
|||
"commit": "c94a49648f0ffff6f24e5770581b0528cc130664"
|
||||
},
|
||||
"_source": "https://github.com/coderaiser/smalltalk.git",
|
||||
"_target": "^2.1.0",
|
||||
"_originalSource": "smalltalk",
|
||||
"_direct": true
|
||||
"_target": "2.1.0",
|
||||
"_originalSource": "smalltalk"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue