native-promise-only
Advanced tools
Comparing version 0.5.0-a to 0.6.0-a
/*! Native Promise Only | ||
v0.5.0-a (c) Kyle Simpson | ||
v0.6.0-a (c) Kyle Simpson | ||
MIT License: http://getify.mit-license.org | ||
@@ -251,3 +251,5 @@ */ | ||
schedule(notify,def); | ||
if (def.state !== 0) { | ||
schedule(notify,def); | ||
} | ||
@@ -258,3 +260,3 @@ return o.promise; | ||
self["catch"] = function $catch$(failure) { | ||
return def.promise.then.call(this,void 0,failure); | ||
return self.then(void 0,failure); | ||
}; | ||
@@ -261,0 +263,0 @@ |
/*! Native Promise Only | ||
v0.5.0-a (c) Kyle Simpson | ||
v0.6.0-a (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(){var t=n;for(n=e=h=null;t;)t.fn.call(t.self),t=t.next}}}function n(t,n){p?(p=!1,t.call(n)):(d.add(t,n),h||(h=y(d.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 p=!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?(p=!0,r.reject(t.msg)):(i=n===!0?t.msg:n.call(void 0,t.msg),p=!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){p=!0,r.reject(c)}}function o(t){if(t.def){if(t.triggered)return p=!1;t.triggered=!0,t=t.def}return 0!==t.state?p=!1:t}function c(t){var i,u,s=o(this);if(s!==!1)try{(i=e(t))?(u=new a(s),i.call(t,function(){c.apply(u,arguments)},function(){f.apply(u,arguments)})):(s.msg=t,s.state=1,n(r,s))}catch(l){f.call(u||new a(s),l)}}function f(t){var e=o(this);e!==!1&&(e.msg=t,e.state=2,n(r,e))}function u(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 a(t){this.def=t,this.triggered=!1}function s(t){this.promise=t,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function l(t){if("function"!=typeof t)throw TypeError("Not a function");if(0!==this.__NPO__)throw TypeError("Not a promise");this.__NPO__=1;var e=this,i=new s(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){if("function"!=typeof(t&&n))throw TypeError("Not a function");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(p=!1):(i.triggered=!0,void c.call(i,t))},function(t){return i.triggered?void(p=!1):(i.triggered=!0,void f.call(i,t))})}catch(o){f.call(i,o)}}var h,d,p=!1,y="undefined"!=typeof setImmediate?function(t){return setImmediate(t)}:setTimeout,v=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};d=t();var g=v({},"constructor",l,!1);return v(l,"prototype",g,!1),v(g,"__NPO__",0,!1),v(l,"resolve",function(t){var e=this;return"object"==typeof t&&"__NPO__"in t?t:new e(function(e,r){if("function"!=typeof(e&&r))throw TypeError("Not a function");n(function(){p=!0,e(t)})})}),v(l,"reject",function(t){return new this(function(n,e){if("function"!=typeof(n&&e))throw TypeError("Not a function");e(t)})}),v(l,"all",function(t){var n=this;return Array.isArray(t)?0===t.length?n.resolve([]):new n(function(e,r){if("function"!=typeof(e&&r))throw TypeError("Not a function");var i=t.length,o=Array(i),c=0;u(n,t,function(t,n){o[t]=n,++c===i&&e(o)},r)}):n.reject(TypeError("Not an array"))}),v(l,"race",function(t){var n=this;return Array.isArray(t)?new n(function(e,r){if("function"!=typeof(e&&r))throw TypeError("Not a function");u(n,t,function(t,n){e(n)},r)}):n.reject(TypeError("Not an array"))}),l}); | ||
!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(o,i){r=new t(o,i),e?e.next=r:n=r,e=r,r=void 0},drain:function(){var t=n;for(n=e=h=null;t;)t.fn.call(t.self),t=t.next}}}function n(t,n){p?(p=!1,t.call(n)):(d.add(t,n),h||(h=y(d.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 p=!1;for(e=0;e<r.chain.length;e++)n=r.chain[e],t=1===r.state?n.success:n.failure,o(r,t,n);r.chain.length=0}function o(t,n,r){var o,i;try{n===!1?(p=!0,r.reject(t.msg)):(o=n===!0?t.msg:n.call(void 0,t.msg),p=!0,o===r.promise?r.reject(TypeError("Promise-chain cycle")):(i=e(o))?i.call(o,r.resolve,r.reject):r.resolve(o))}catch(c){p=!0,r.reject(c)}}function i(t){if(t.def){if(t.triggered)return p=!1;t.triggered=!0,t=t.def}return 0!==t.state?p=!1:t}function c(t){var o,u,s=i(this);if(s!==!1)try{(o=e(t))?(u=new a(s),o.call(t,function(){c.apply(u,arguments)},function(){f.apply(u,arguments)})):(s.msg=t,s.state=1,n(r,s))}catch(l){f.call(u||new a(s),l)}}function f(t){var e=i(this);e!==!1&&(e.msg=t,e.state=2,n(r,e))}function u(t,n,e,r){for(var o=0;o<n.length;o++)!function(o){t.resolve(n[o]).then(function(t){e(o,t)},r)}(o)}function a(t){this.def=t,this.triggered=!1}function s(t){this.promise=t,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function l(t){if("function"!=typeof t)throw TypeError("Not a function");if(0!==this.__NPO__)throw TypeError("Not a promise");this.__NPO__=1;var e=this,o=new s(e);e.then=function(t,e){var i={success:"function"==typeof t?t:!0,failure:"function"==typeof e?e:!1};return i.promise=new this.constructor(function(t,n){if("function"!=typeof(t&&n))throw TypeError("Not a function");i.resolve=t,i.reject=n}),o.chain.push(i),0!==o.state&&n(r,o),i.promise},e["catch"]=function(t){return e.then(void 0,t)};try{t.call(void 0,function(t){return o.triggered?void(p=!1):(o.triggered=!0,void c.call(o,t))},function(t){return o.triggered?void(p=!1):(o.triggered=!0,void f.call(o,t))})}catch(i){f.call(o,i)}}var h,d,p=!1,y="undefined"!=typeof setImmediate?function(t){return setImmediate(t)}:setTimeout,v=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};d=t();var g=v({},"constructor",l,!1);return v(l,"prototype",g,!1),v(g,"__NPO__",0,!1),v(l,"resolve",function(t){var e=this;return"object"==typeof t&&"__NPO__"in t?t:new e(function(e,r){if("function"!=typeof(e&&r))throw TypeError("Not a function");n(function(){p=!0,e(t)})})}),v(l,"reject",function(t){return new this(function(n,e){if("function"!=typeof(n&&e))throw TypeError("Not a function");e(t)})}),v(l,"all",function(t){var n=this;return Array.isArray(t)?0===t.length?n.resolve([]):new n(function(e,r){if("function"!=typeof(e&&r))throw TypeError("Not a function");var o=t.length,i=Array(o),c=0;u(n,t,function(t,n){i[t]=n,++c===o&&e(i)},r)}):n.reject(TypeError("Not an array"))}),v(l,"race",function(t){var n=this;return Array.isArray(t)?new n(function(e,r){if("function"!=typeof(e&&r))throw TypeError("Not a function");u(n,t,function(t,n){e(n)},r)}):n.reject(TypeError("Not an array"))}),l}); |
{ | ||
"name": "native-promise-only", | ||
"version": "0.5.0-a", | ||
"version": "0.6.0-a", | ||
"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
21422
387