native-promise-only
Advanced tools
Comparing version 0.4.1-c to 0.4.1-d
/*! Native Promise Only | ||
v0.4.1-c (c) Kyle Simpson | ||
v0.4.1-d (c) Kyle Simpson | ||
MIT License: http://getify.mit-license.org | ||
@@ -217,8 +217,5 @@ */ | ||
function checkCapability(resolve,reject) { | ||
if (typeof resolve !== "function") { | ||
if (typeof (resolve && reject) !== "function") { | ||
throw TypeError("Not a function"); | ||
} | ||
if (typeof reject !== "function") { | ||
throw TypeError("Not a function"); | ||
} | ||
} | ||
@@ -225,0 +222,0 @@ |
/*! Native Promise Only | ||
v0.4.1-c (c) Kyle Simpson | ||
v0.4.1-d (c) Kyle Simpson | ||
MIT License: http://getify.mit-license.org | ||
*/ | ||
!function(t,n,e){n[t]=n[t]||e(),"undefined"!=typeof module&&module.exports?module.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof global?global:this,function(){"use strict";function t(){function t(t,n){this.fn=t,this.self=n,this.next=void 0}var n,e,r;return{add:function(i,o){r=new t(i,o),e?e.next=r:n=r,e=r,r=void 0},drain:function(){for(;n;)n.fn.call(n.self),n=n.next;g=e=n}}}function n(t,n){y?(y=!1,t.call(n)):(v.add(t,n),g||(g=m(v.drain)))}function e(t){var n,e=typeof t;return null===t||"object"!==e&&"function"!==e||(n=t.then),"function"==typeof n?n:!1}function r(){var t,n,e,r=this;if(0===r.state)return y=!1;for(e=0;e<r.chain.length;e++)n=r.chain[e],t=1===r.state?n.success:n.failure,i(r,t,n);r.chain.length=0}function i(t,n,r){var i,o;try{n===!1?(y=!0,r.reject(t.msg)):(i=n===!0?t.msg:n.call(void 0,t.msg),y=!0,i===r.promise?r.reject(TypeError("Promise-chain cycle")):(o=e(i))?o.call(i,r.resolve,r.reject):r.resolve(i))}catch(c){y=!0,r.reject(c)}}function o(t){if(t.def){if(t.triggered)return y=!1;t.triggered=!0,t=t.def}return 0!==t.state?y=!1:t}function c(t){var i,u,a=o(this);if(a!==!1)try{(i=e(t))?(u=new d(a),i.call(t,function(){c.apply(u,arguments)},function(){f.apply(u,arguments)})):(a.msg=t,a.state=1,n(r,a))}catch(s){f.call(u||new d(a),s)}}function f(t){var e=o(this);e!==!1&&(e.msg=t,e.state=2,n(r,e))}function u(t,n){y=!0,t(n)}function a(t,n,e,r){for(var i=0;i<n.length;i++)!function(i){t.resolve(n[i]).then(function(t){e(i,t)},r)}(i)}function s(t,n){return Array.isArray(n)?void 0:t.reject(TypeError("Not an array"))}function l(t,n){if("function"!=typeof t)throw TypeError("Not a function");if("function"!=typeof n)throw TypeError("Not a function")}function d(t){this.def=t,this.triggered=!1}function h(t){this.promise=t,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function p(t){if("function"!=typeof t)throw TypeError("Not a function");var e=this,i=new h(e);e.then=function(t,e){var o={success:"function"==typeof t?t:!0,failure:"function"==typeof e?e:!1};return o.promise=new this.constructor(function(t,n){l(t,n),o.resolve=t,o.reject=n}),i.chain.push(o),n(r,i),o.promise},e["catch"]=function(t){return i.promise.then.call(this,void 0,t)};try{t.call(void 0,function(t){return i.triggered?void(y=!1):(i.triggered=!0,void c.call(i,t))},function(t){return i.triggered?void(y=!1):(i.triggered=!0,void f.call(i,t))})}catch(o){f.call(i,o)}}var g,v,y=!1,m="undefined"!=typeof setImmediate?function(t){return setImmediate(t)}:setTimeout,w=Object.defineProperty?function(t,n,e,r){return Object.defineProperty(t,n,{value:e,writable:!0,configurable:r!==!1})}:function(t,n,e){return t[n]=e,t};return v=t(),w(p,"prototype",w({},"constructor",p),!1),w(p,"resolve",function(t){var e=this;return"object"==typeof t&&t instanceof e?t:new e(function(e,r){l(e,r),n(function(){u(e,t)})})}),w(p,"reject",function(t){return new this(function(n,e){l(n,e),e(t)})}),w(p,"all",function(t){var n,e=this;return(n=s(e,t))?n:0===t.length?e.resolve([]):new e(function(n,r){l(n,r);var i=t.length,o=Array(i),c=0;a(e,t,function(t,e){o[t]=e,++c===i&&u(n,o)},r)})}),w(p,"race",function(t){var n,e=this;return(n=s(e,t))?n:new e(function(n,r){l(n,r),a(e,t,function(t,e){u(n,e)},r)})}),p}); | ||
!function(t,n,e){n[t]=n[t]||e(),"undefined"!=typeof module&&module.exports?module.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof global?global:this,function(){"use strict";function t(){function t(t,n){this.fn=t,this.self=n,this.next=void 0}var n,e,r;return{add:function(i,o){r=new t(i,o),e?e.next=r:n=r,e=r,r=void 0},drain:function(){for(;n;)n.fn.call(n.self),n=n.next;v=e=n}}}function n(t,n){y?(y=!1,t.call(n)):(p.add(t,n),v||(v=m(p.drain)))}function e(t){var n,e=typeof t;return null===t||"object"!==e&&"function"!==e||(n=t.then),"function"==typeof n?n:!1}function r(){var t,n,e,r=this;if(0===r.state)return y=!1;for(e=0;e<r.chain.length;e++)n=r.chain[e],t=1===r.state?n.success:n.failure,i(r,t,n);r.chain.length=0}function i(t,n,r){var i,o;try{n===!1?(y=!0,r.reject(t.msg)):(i=n===!0?t.msg:n.call(void 0,t.msg),y=!0,i===r.promise?r.reject(TypeError("Promise-chain cycle")):(o=e(i))?o.call(i,r.resolve,r.reject):r.resolve(i))}catch(c){y=!0,r.reject(c)}}function o(t){if(t.def){if(t.triggered)return y=!1;t.triggered=!0,t=t.def}return 0!==t.state?y=!1:t}function c(t){var i,u,a=o(this);if(a!==!1)try{(i=e(t))?(u=new d(a),i.call(t,function(){c.apply(u,arguments)},function(){f.apply(u,arguments)})):(a.msg=t,a.state=1,n(r,a))}catch(s){f.call(u||new d(a),s)}}function f(t){var e=o(this);e!==!1&&(e.msg=t,e.state=2,n(r,e))}function u(t,n){y=!0,t(n)}function a(t,n,e,r){for(var i=0;i<n.length;i++)!function(i){t.resolve(n[i]).then(function(t){e(i,t)},r)}(i)}function s(t,n){return Array.isArray(n)?void 0:t.reject(TypeError("Not an array"))}function l(t,n){if("function"!=typeof(t&&n))throw TypeError("Not a function")}function d(t){this.def=t,this.triggered=!1}function h(t){this.promise=t,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function g(t){if("function"!=typeof t)throw TypeError("Not a function");var e=this,i=new h(e);e.then=function(t,e){var o={success:"function"==typeof t?t:!0,failure:"function"==typeof e?e:!1};return o.promise=new this.constructor(function(t,n){l(t,n),o.resolve=t,o.reject=n}),i.chain.push(o),n(r,i),o.promise},e["catch"]=function(t){return i.promise.then.call(this,void 0,t)};try{t.call(void 0,function(t){return i.triggered?void(y=!1):(i.triggered=!0,void c.call(i,t))},function(t){return i.triggered?void(y=!1):(i.triggered=!0,void f.call(i,t))})}catch(o){f.call(i,o)}}var v,p,y=!1,m="undefined"!=typeof setImmediate?function(t){return setImmediate(t)}:setTimeout,w=Object.defineProperty?function(t,n,e,r){return Object.defineProperty(t,n,{value:e,writable:!0,configurable:r!==!1})}:function(t,n,e){return t[n]=e,t};return p=t(),w(g,"prototype",w({},"constructor",g),!1),w(g,"resolve",function(t){var e=this;return"object"==typeof t&&t instanceof e?t:new e(function(e,r){l(e,r),n(function(){u(e,t)})})}),w(g,"reject",function(t){return new this(function(n,e){l(n,e),e(t)})}),w(g,"all",function(t){var n,e=this;return(n=s(e,t))?n:0===t.length?e.resolve([]):new e(function(n,r){l(n,r);var i=t.length,o=Array(i),c=0;a(e,t,function(t,e){o[t]=e,++c===i&&u(n,o)},r)})}),w(g,"race",function(t){var n,e=this;return(n=s(e,t))?n:new e(function(n,r){l(n,r),a(e,t,function(t,e){u(n,e)},r)})}),g}); |
{ | ||
"name": "native-promise-only", | ||
"version": "0.4.1-c", | ||
"version": "0.4.1-d", | ||
"description": "Native Promise Only: A polyfill for native ES6 Promises **only**, nothing else.", | ||
@@ -5,0 +5,0 @@ "main": "./npo.js", |
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
20901
374