Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

native-promise-only

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

native-promise-only - npm Package Compare versions

Comparing version 0.4.1-d to 0.4.1-e

48

lib/npo.src.js
/*! Native Promise Only
v0.4.1-d (c) Kyle Simpson
v0.4.1-e (c) Kyle Simpson
MIT License: http://getify.mit-license.org

@@ -210,14 +210,2 @@ */

function checkArray(Constructor,arr) {
if (!Array.isArray(arr)) {
return Constructor.reject(TypeError("Not an array"));
}
}
function checkCapability(resolve,reject) {
if (typeof (resolve && reject) !== "function") {
throw TypeError("Not a function");
}
}
function MakeDefWrapper(self) {

@@ -252,3 +240,5 @@ this.def = self;

o.promise = new this.constructor(function extractChain(resolve,reject) {
checkCapability(resolve,reject);
if (typeof (resolve && reject) !== "function") {
throw TypeError("Not a function");
}

@@ -309,3 +299,6 @@ o.resolve = resolve;

return new Constructor(function executor(resolve,reject){
checkCapability(resolve,reject);
if (typeof (resolve && reject) !== "function") {
throw TypeError("Not a function");
}
schedule(function $immediateResolve$(){

@@ -319,3 +312,6 @@ immediateResolve(resolve,msg);

return new this(function executor(resolve,reject){
checkCapability(resolve,reject);
if (typeof (resolve && reject) !== "function") {
throw TypeError("Not a function");
}
reject(msg);

@@ -326,7 +322,7 @@ });

builtInProp(Promise,"all",function Promise$all(arr) {
var err, Constructor = this;
var Constructor = this;
// spec mandated checks
if (err = checkArray(Constructor,arr)) {
return err;
if (!Array.isArray(arr)) {
return Constructor.reject(TypeError("Not an array"));
}

@@ -338,3 +334,5 @@ if (arr.length === 0) {

return new Constructor(function executor(resolve,reject){
checkCapability(resolve,reject);
if (typeof (resolve && reject) !== "function") {
throw TypeError("Not a function");
}

@@ -353,11 +351,13 @@ var len = arr.length, msgs = Array(len), count = 0;

builtInProp(Promise,"race",function Promise$race(arr) {
var err, Constructor = this;
var Constructor = this;
// spec mandated checks
if (err = checkArray(Constructor,arr)) {
return err;
if (!Array.isArray(arr)) {
return Constructor.reject(TypeError("Not an array"));
}
return new Constructor(function executor(resolve,reject){
checkCapability(resolve,reject);
if (typeof (resolve && reject) !== "function") {
throw TypeError("Not a function");
}

@@ -364,0 +364,0 @@ iteratePromises(Constructor,arr,function resolver(idx,msg){

/*! Native Promise Only
v0.4.1-d (c) Kyle Simpson
v0.4.1-e (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;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});
!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(){for(;n;)n.fn.call(n.self),n=n.next;d=e=n}}}function n(t,n){y?(y=!1,t.call(n)):(p.add(t,n),d||(d=g(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,o(r,t,n);r.chain.length=0}function o(t,n,r){var o,i;try{n===!1?(y=!0,r.reject(t.msg)):(o=n===!0?t.msg:n.call(void 0,t.msg),y=!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){y=!0,r.reject(c)}}function i(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 o,u,a=i(this);if(a!==!1)try{(o=e(t))?(u=new s(a),o.call(t,function(){c.apply(u,arguments)},function(){f.apply(u,arguments)})):(a.msg=t,a.state=1,n(r,a))}catch(l){f.call(u||new s(a),l)}}function f(t){var e=i(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 o=0;o<n.length;o++)!function(o){t.resolve(n[o]).then(function(t){e(o,t)},r)}(o)}function s(t){this.def=t,this.triggered=!1}function l(t){this.promise=t,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function h(t){if("function"!=typeof t)throw TypeError("Not a function");var e=this,o=new l(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),n(r,o),i.promise},e["catch"]=function(t){return o.promise.then.call(this,void 0,t)};try{t.call(void 0,function(t){return o.triggered?void(y=!1):(o.triggered=!0,void c.call(o,t))},function(t){return o.triggered?void(y=!1):(o.triggered=!0,void f.call(o,t))})}catch(i){f.call(o,i)}}var d,p,y=!1,g="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};return p=t(),v(h,"prototype",v({},"constructor",h),!1),v(h,"resolve",function(t){var e=this;return"object"==typeof t&&t instanceof e?t:new e(function(e,r){if("function"!=typeof(e&&r))throw TypeError("Not a function");n(function(){u(e,t)})})}),v(h,"reject",function(t){return new this(function(n,e){if("function"!=typeof(n&&e))throw TypeError("Not a function");e(t)})}),v(h,"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;a(n,t,function(t,n){i[t]=n,++c===o&&u(e,i)},r)}):n.reject(TypeError("Not an array"))}),v(h,"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");a(n,t,function(t,n){u(e,n)},r)}):n.reject(TypeError("Not an array"))}),h});
{
"name": "native-promise-only",
"version": "0.4.1-d",
"version": "0.4.1-e",
"description": "Native Promise Only: A polyfill for native ES6 Promises **only**, nothing else.",

@@ -5,0 +5,0 @@ "main": "./npo.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc