promise-polyfill
Advanced tools
Comparing version 8.1.0 to 8.1.1
# Changelog | ||
### 8.1.0 | ||
* Added Closure compiler type definitions | ||
### 8.0.0 | ||
@@ -4,0 +8,0 @@ |
@@ -14,2 +14,3 @@ (function (global, factory) { | ||
function(value) { | ||
// @ts-ignore | ||
return constructor.resolve(callback()).then(function() { | ||
@@ -20,3 +21,5 @@ return value; | ||
function(reason) { | ||
// @ts-ignore | ||
return constructor.resolve(callback()).then(function() { | ||
// @ts-ignore | ||
return constructor.reject(reason); | ||
@@ -32,2 +35,6 @@ }); | ||
function isArray(x) { | ||
return Boolean(x && x.length); | ||
} | ||
function noop() {} | ||
@@ -190,4 +197,6 @@ | ||
return new Promise(function(resolve, reject) { | ||
if (!arr || typeof arr.length === 'undefined') | ||
throw new TypeError('Promise.all accepts an array'); | ||
if (!isArray(arr)) { | ||
return reject(new TypeError('Promise.all accepts an array')); | ||
} | ||
var args = Array.prototype.slice.call(arr); | ||
@@ -243,7 +252,11 @@ if (args.length === 0) return resolve([]); | ||
Promise.race = function(values) { | ||
Promise.race = function(arr) { | ||
return new Promise(function(resolve, reject) { | ||
for (var i = 0, len = values.length; i < len; i++) { | ||
values[i].then(resolve, reject); | ||
if (!isArray(arr)) { | ||
return reject(new TypeError('Promise.race accepts an array')); | ||
} | ||
for (var i = 0, len = arr.length; i < len; i++) { | ||
Promise.resolve(arr[i]).then(resolve, reject); | ||
} | ||
}); | ||
@@ -254,4 +267,6 @@ }; | ||
Promise._immediateFn = | ||
// @ts-ignore | ||
(typeof setImmediate === 'function' && | ||
function(fn) { | ||
// @ts-ignore | ||
setImmediate(fn); | ||
@@ -258,0 +273,0 @@ }) || |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";function e(e){var n=this.constructor;return this.then(function(t){return n.resolve(e()).then(function(){return t})},function(t){return n.resolve(e()).then(function(){return n.reject(t)})})}function n(){}function t(e){if(!(this instanceof t))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=undefined,this._deferreds=[],u(e,this)}function o(e,n){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,t._immediateFn(function(){var t=1===e._state?n.onFulfilled:n.onRejected;if(null!==t){var o;try{o=t(e._value)}catch(f){return void i(n.promise,f)}r(n.promise,o)}else(1===e._state?r:i)(n.promise,e._value)})):e._deferreds.push(n)}function r(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var o=n.then;if(n instanceof t)return e._state=3,e._value=n,void f(e);if("function"==typeof o)return void u(function(e,n){return function(){e.apply(n,arguments)}}(o,n),e)}e._state=1,e._value=n,f(e)}catch(r){i(e,r)}}function i(e,n){e._state=2,e._value=n,f(e)}function f(e){2===e._state&&0===e._deferreds.length&&t._immediateFn(function(){e._handled||t._unhandledRejectionFn(e._value)});for(var n=0,r=e._deferreds.length;r>n;n++)o(e,e._deferreds[n]);e._deferreds=null}function u(e,n){var t=!1;try{e(function(e){t||(t=!0,r(n,e))},function(e){t||(t=!0,i(n,e))})}catch(o){if(t)return;t=!0,i(n,o)}}var c=setTimeout;t.prototype["catch"]=function(e){return this.then(null,e)},t.prototype.then=function(e,t){var r=new this.constructor(n);return o(this,new function(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}(e,t,r)),r},t.prototype["finally"]=e,t.all=function(e){return new t(function(n,t){function o(e,f){try{if(f&&("object"==typeof f||"function"==typeof f)){var u=f.then;if("function"==typeof u)return void u.call(f,function(n){o(e,n)},t)}r[e]=f,0==--i&&n(r)}catch(c){t(c)}}if(!e||"undefined"==typeof e.length)throw new TypeError("Promise.all accepts an array");var r=Array.prototype.slice.call(e);if(0===r.length)return n([]);for(var i=r.length,f=0;r.length>f;f++)o(f,r[f])})},t.resolve=function(e){return e&&"object"==typeof e&&e.constructor===t?e:new t(function(n){n(e)})},t.reject=function(e){return new t(function(n,t){t(e)})},t.race=function(e){return new t(function(n,t){for(var o=0,r=e.length;r>o;o++)e[o].then(n,t)})},t._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){c(e,0)},t._unhandledRejectionFn=function(e){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var l=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw Error("unable to locate global object")}();"Promise"in l?l.Promise.prototype["finally"]||(l.Promise.prototype["finally"]=e):l.Promise=t}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";function e(e){var n=this.constructor;return this.then(function(t){return n.resolve(e()).then(function(){return t})},function(t){return n.resolve(e()).then(function(){return n.reject(t)})})}function n(e){return!(!e||!e.length)}function t(){}function o(e){if(!(this instanceof o))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=undefined,this._deferreds=[],c(e,this)}function r(e,n){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,o._immediateFn(function(){var t=1===e._state?n.onFulfilled:n.onRejected;if(null!==t){var o;try{o=t(e._value)}catch(r){return void f(n.promise,r)}i(n.promise,o)}else(1===e._state?i:f)(n.promise,e._value)})):e._deferreds.push(n)}function i(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var t=n.then;if(n instanceof o)return e._state=3,e._value=n,void u(e);if("function"==typeof t)return void c(function(e,n){return function(){e.apply(n,arguments)}}(t,n),e)}e._state=1,e._value=n,u(e)}catch(r){f(e,r)}}function f(e,n){e._state=2,e._value=n,u(e)}function u(e){2===e._state&&0===e._deferreds.length&&o._immediateFn(function(){e._handled||o._unhandledRejectionFn(e._value)});for(var n=0,t=e._deferreds.length;t>n;n++)r(e,e._deferreds[n]);e._deferreds=null}function c(e,n){var t=!1;try{e(function(e){t||(t=!0,i(n,e))},function(e){t||(t=!0,f(n,e))})}catch(o){if(t)return;t=!0,f(n,o)}}var a=setTimeout;o.prototype["catch"]=function(e){return this.then(null,e)},o.prototype.then=function(e,n){var o=new this.constructor(t);return r(this,new function(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}(e,n,o)),o},o.prototype["finally"]=e,o.all=function(e){return new o(function(t,o){function r(e,n){try{if(n&&("object"==typeof n||"function"==typeof n)){var u=n.then;if("function"==typeof u)return void u.call(n,function(n){r(e,n)},o)}i[e]=n,0==--f&&t(i)}catch(c){o(c)}}if(!n(e))return o(new TypeError("Promise.all accepts an array"));var i=Array.prototype.slice.call(e);if(0===i.length)return t([]);for(var f=i.length,u=0;i.length>u;u++)r(u,i[u])})},o.resolve=function(e){return e&&"object"==typeof e&&e.constructor===o?e:new o(function(n){n(e)})},o.reject=function(e){return new o(function(n,t){t(e)})},o.race=function(e){return new o(function(t,r){if(!n(e))return r(new TypeError("Promise.race accepts an array"));for(var i=0,f=e.length;f>i;i++)o.resolve(e[i]).then(t,r)})},o._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){a(e,0)},o._unhandledRejectionFn=function(e){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var l=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw Error("unable to locate global object")}();"Promise"in l?l.Promise.prototype["finally"]||(l.Promise.prototype["finally"]=e):l.Promise=o}); |
@@ -10,2 +10,3 @@ 'use strict'; | ||
function(value) { | ||
// @ts-ignore | ||
return constructor.resolve(callback()).then(function() { | ||
@@ -16,3 +17,5 @@ return value; | ||
function(reason) { | ||
// @ts-ignore | ||
return constructor.resolve(callback()).then(function() { | ||
// @ts-ignore | ||
return constructor.reject(reason); | ||
@@ -28,2 +31,6 @@ }); | ||
function isArray(x) { | ||
return Boolean(x && x.length); | ||
} | ||
function noop() {} | ||
@@ -186,4 +193,6 @@ | ||
return new Promise(function(resolve, reject) { | ||
if (!arr || typeof arr.length === 'undefined') | ||
throw new TypeError('Promise.all accepts an array'); | ||
if (!isArray(arr)) { | ||
return reject(new TypeError('Promise.all accepts an array')); | ||
} | ||
var args = Array.prototype.slice.call(arr); | ||
@@ -239,7 +248,11 @@ if (args.length === 0) return resolve([]); | ||
Promise.race = function(values) { | ||
Promise.race = function(arr) { | ||
return new Promise(function(resolve, reject) { | ||
for (var i = 0, len = values.length; i < len; i++) { | ||
values[i].then(resolve, reject); | ||
if (!isArray(arr)) { | ||
return reject(new TypeError('Promise.race accepts an array')); | ||
} | ||
for (var i = 0, len = arr.length; i < len; i++) { | ||
Promise.resolve(arr[i]).then(resolve, reject); | ||
} | ||
}); | ||
@@ -250,4 +263,6 @@ }; | ||
Promise._immediateFn = | ||
// @ts-ignore | ||
(typeof setImmediate === 'function' && | ||
function(fn) { | ||
// @ts-ignore | ||
setImmediate(fn); | ||
@@ -254,0 +269,0 @@ }) || |
@@ -10,2 +10,3 @@ 'use strict'; | ||
function(value) { | ||
// @ts-ignore | ||
return constructor.resolve(callback()).then(function() { | ||
@@ -16,3 +17,5 @@ return value; | ||
function(reason) { | ||
// @ts-ignore | ||
return constructor.resolve(callback()).then(function() { | ||
// @ts-ignore | ||
return constructor.reject(reason); | ||
@@ -28,2 +31,6 @@ }); | ||
function isArray(x) { | ||
return Boolean(x && x.length); | ||
} | ||
function noop() {} | ||
@@ -186,4 +193,6 @@ | ||
return new Promise(function(resolve, reject) { | ||
if (!arr || typeof arr.length === 'undefined') | ||
throw new TypeError('Promise.all accepts an array'); | ||
if (!isArray(arr)) { | ||
return reject(new TypeError('Promise.all accepts an array')); | ||
} | ||
var args = Array.prototype.slice.call(arr); | ||
@@ -239,7 +248,11 @@ if (args.length === 0) return resolve([]); | ||
Promise.race = function(values) { | ||
Promise.race = function(arr) { | ||
return new Promise(function(resolve, reject) { | ||
for (var i = 0, len = values.length; i < len; i++) { | ||
values[i].then(resolve, reject); | ||
if (!isArray(arr)) { | ||
return reject(new TypeError('Promise.race accepts an array')); | ||
} | ||
for (var i = 0, len = arr.length; i < len; i++) { | ||
Promise.resolve(arr[i]).then(resolve, reject); | ||
} | ||
}); | ||
@@ -250,4 +263,6 @@ }; | ||
Promise._immediateFn = | ||
// @ts-ignore | ||
(typeof setImmediate === 'function' && | ||
function(fn) { | ||
// @ts-ignore | ||
setImmediate(fn); | ||
@@ -254,0 +269,0 @@ }) || |
{ | ||
"name": "promise-polyfill", | ||
"version": "8.1.0", | ||
"version": "8.1.1", | ||
"description": "Lightweight promise polyfill. A+ compliant", | ||
@@ -41,2 +41,3 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"browserify": "^16.2.3", | ||
"cross-env": "^5.1.1", | ||
@@ -46,8 +47,8 @@ "eslint": "^4.11.0", | ||
"husky": "^0.14.3", | ||
"karma": "^0.13.19", | ||
"karma-browserify": "^4.4.2", | ||
"karma": "^4.1.0", | ||
"karma-browserify": "^6.0.0", | ||
"karma-chrome-launcher": "^0.2.2", | ||
"karma-mocha": "^0.2.1", | ||
"lint-staged": "^5.0.0", | ||
"mocha": "^2.3.4", | ||
"mocha": "^6.1.4", | ||
"npm-run-all": "^4.1.2", | ||
@@ -60,3 +61,4 @@ "prettier": "^1.8.2", | ||
"sinon": "^1.17.2", | ||
"typescript": "^2.9.2" | ||
"typescript": "^3.5.1", | ||
"watchify": "^3.11.1" | ||
}, | ||
@@ -63,0 +65,0 @@ "keywords": [ |
@@ -9,3 +9,3 @@ # Promise Polyfill | ||
Lightweight ES6 Promise polyfill for the browser and node. Adheres closely to | ||
the spec. It is a perfect polyfill IE, Firefox or any other browser that does | ||
the spec. It is a perfect polyfill IE or any other browser that does | ||
not support native promises. | ||
@@ -56,3 +56,3 @@ | ||
If you would like to not affect the global environment (sometimes known as a [ponyfill](ponyfill.com)), you can import the base module. This is nice for library authors or people working in environment where you don't want | ||
If you would like to not affect the global environment (sometimes known as a [ponyfill](https://github.com/sindresorhus/ponyfill), you can import the base module. This is nice for library authors or people working in environment where you don't want | ||
to affect the global environment. | ||
@@ -59,0 +59,0 @@ |
@@ -8,2 +8,3 @@ /** | ||
function(value) { | ||
// @ts-ignore | ||
return constructor.resolve(callback()).then(function() { | ||
@@ -14,3 +15,5 @@ return value; | ||
function(reason) { | ||
// @ts-ignore | ||
return constructor.resolve(callback()).then(function() { | ||
// @ts-ignore | ||
return constructor.reject(reason); | ||
@@ -17,0 +20,0 @@ }); |
@@ -7,2 +7,6 @@ import promiseFinally from './finally'; | ||
function isArray(x) { | ||
return Boolean(x && x.length); | ||
} | ||
function noop() {} | ||
@@ -165,4 +169,6 @@ | ||
return new Promise(function(resolve, reject) { | ||
if (!arr || typeof arr.length === 'undefined') | ||
throw new TypeError('Promise.all accepts an array'); | ||
if (!isArray(arr)) { | ||
return reject(new TypeError('Promise.all accepts an array')); | ||
} | ||
var args = Array.prototype.slice.call(arr); | ||
@@ -218,7 +224,11 @@ if (args.length === 0) return resolve([]); | ||
Promise.race = function(values) { | ||
Promise.race = function(arr) { | ||
return new Promise(function(resolve, reject) { | ||
for (var i = 0, len = values.length; i < len; i++) { | ||
values[i].then(resolve, reject); | ||
if (!isArray(arr)) { | ||
return reject(new TypeError('Promise.race accepts an array')); | ||
} | ||
for (var i = 0, len = arr.length; i < len; i++) { | ||
Promise.resolve(arr[i]).then(resolve, reject); | ||
} | ||
}); | ||
@@ -229,4 +239,6 @@ }; | ||
Promise._immediateFn = | ||
// @ts-ignore | ||
(typeof setImmediate === 'function' && | ||
function(fn) { | ||
// @ts-ignore | ||
setImmediate(fn); | ||
@@ -233,0 +245,0 @@ }) || |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42354
1058
20