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

promise

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise - npm Package Compare versions

Comparing version 8.0.1 to 8.0.2

23

build.js

@@ -7,15 +7,15 @@ 'use strict';

var walk = require('acorn/dist/walk');
var crypto = require('crypto');
var ids = [];
var names = {};
var shasum = crypto.createHash('sha512');
fs.readdirSync(__dirname + '/src').sort().forEach(function (filename) {
shasum.update(fs.readFileSync(__dirname + '/src/' + filename, 'utf8'));
});
const names = {};
const characterSet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
let i = characterSet.indexOf(shasum.digest('base64').replace(/[^0-9a-zA-Z]/g, '')[0]);
function getIdFor(name) {
if (name in names) return names[name];
var id;
do {
id = '_' + Math.floor(Math.random() * 100);
} while (ids.indexOf(id) !== -1)
ids.push(id);
names[name] = id;
return id;
if (names[name]) return names[name];
return names[name] = '_' + characterSet[i++ % characterSet.length]
}

@@ -34,5 +34,2 @@

});
function source(node) {
return src.slice(node.start, node.end).join('');
}
function replace(node, str) {

@@ -39,0 +36,0 @@ for (var i = node.start; i < node.end; i++) {

@@ -61,12 +61,12 @@ 'use strict';

}
this._75 = 0;
this._83 = 0;
this._18 = null;
this._38 = null;
this._h = 0;
this._i = 0;
this._j = null;
this._k = null;
if (fn === noop) return;
doResolve(fn, this);
}
Promise._47 = null;
Promise._71 = null;
Promise._44 = noop;
Promise._l = null;
Promise._m = null;
Promise._n = noop;

@@ -90,20 +90,20 @@ Promise.prototype.then = function(onFulfilled, onRejected) {

function handle(self, deferred) {
while (self._83 === 3) {
self = self._18;
while (self._i === 3) {
self = self._j;
}
if (Promise._47) {
Promise._47(self);
if (Promise._l) {
Promise._l(self);
}
if (self._83 === 0) {
if (self._75 === 0) {
self._75 = 1;
self._38 = deferred;
if (self._i === 0) {
if (self._h === 0) {
self._h = 1;
self._k = deferred;
return;
}
if (self._75 === 1) {
self._75 = 2;
self._38 = [self._38, deferred];
if (self._h === 1) {
self._h = 2;
self._k = [self._k, deferred];
return;
}
self._38.push(deferred);
self._k.push(deferred);
return;

@@ -116,12 +116,12 @@ }

asap(function() {
var cb = self._83 === 1 ? deferred.onFulfilled : deferred.onRejected;
var cb = self._i === 1 ? deferred.onFulfilled : deferred.onRejected;
if (cb === null) {
if (self._83 === 1) {
resolve(deferred.promise, self._18);
if (self._i === 1) {
resolve(deferred.promise, self._j);
} else {
reject(deferred.promise, self._18);
reject(deferred.promise, self._j);
}
return;
}
var ret = tryCallOne(cb, self._18);
var ret = tryCallOne(cb, self._j);
if (ret === IS_ERROR) {

@@ -154,4 +154,4 @@ reject(deferred.promise, LAST_ERROR);

) {
self._83 = 3;
self._18 = newValue;
self._i = 3;
self._j = newValue;
finale(self);

@@ -164,4 +164,4 @@ return;

}
self._83 = 1;
self._18 = newValue;
self._i = 1;
self._j = newValue;
finale(self);

@@ -171,6 +171,6 @@ }

function reject(self, newValue) {
self._83 = 2;
self._18 = newValue;
if (Promise._71) {
Promise._71(self, newValue);
self._i = 2;
self._j = newValue;
if (Promise._m) {
Promise._m(self, newValue);
}

@@ -180,11 +180,11 @@ finale(self);

function finale(self) {
if (self._75 === 1) {
handle(self, self._38);
self._38 = null;
if (self._h === 1) {
handle(self, self._k);
self._k = null;
}
if (self._75 === 2) {
for (var i = 0; i < self._38.length; i++) {
handle(self, self._38[i]);
if (self._h === 2) {
for (var i = 0; i < self._k.length; i++) {
handle(self, self._k[i]);
}
self._38 = null;
self._k = null;
}

@@ -191,0 +191,0 @@ }

@@ -19,5 +19,5 @@ 'use strict';

function valuePromise(value) {
var p = new Promise(Promise._44);
p._83 = 1;
p._18 = value;
var p = new Promise(Promise._n);
p._i = 1;
p._j = value;
return p;

@@ -59,7 +59,7 @@ }

if (val instanceof Promise && val.then === Promise.prototype.then) {
while (val._83 === 3) {
val = val._18;
while (val._i === 3) {
val = val._j;
}
if (val._83 === 1) return res(i, val._18);
if (val._83 === 2) reject(val._18);
if (val._i === 1) return res(i, val._j);
if (val._i === 2) reject(val._j);
val.then(function (val) {

@@ -66,0 +66,0 @@ res(i, val);

@@ -6,3 +6,3 @@ 'use strict';

module.exports = Promise;
Promise.prototype['finally'] = function (f) {
Promise.prototype.finally = function (f) {
return this.then(function (value) {

@@ -9,0 +9,0 @@ return Promise.resolve(f()).then(function () {

@@ -15,4 +15,4 @@ 'use strict';

enabled = false;
Promise._47 = null;
Promise._71 = null;
Promise._l = null;
Promise._m = null;
}

@@ -28,23 +28,23 @@

var rejections = {};
Promise._47 = function (promise) {
Promise._l = function (promise) {
if (
promise._83 === 2 && // IS REJECTED
rejections[promise._56]
promise._i === 2 && // IS REJECTED
rejections[promise._o]
) {
if (rejections[promise._56].logged) {
onHandled(promise._56);
if (rejections[promise._o].logged) {
onHandled(promise._o);
} else {
clearTimeout(rejections[promise._56].timeout);
clearTimeout(rejections[promise._o].timeout);
}
delete rejections[promise._56];
delete rejections[promise._o];
}
};
Promise._71 = function (promise, err) {
if (promise._75 === 0) { // not yet handled
promise._56 = id++;
rejections[promise._56] = {
Promise._m = function (promise, err) {
if (promise._h === 0) { // not yet handled
promise._o = id++;
rejections[promise._o] = {
displayId: null,
error: err,
timeout: setTimeout(
onUnhandled.bind(null, promise._56),
onUnhandled.bind(null, promise._o),
// For reference errors and type errors, this almost always

@@ -51,0 +51,0 @@ // means the programmer made a mistake, so log them after just

@@ -20,4 +20,4 @@ 'use strict';

Promise.prototype.getValue = function () {
if (this._83 === 3) {
return this._18.getValue();
if (this._i === 3) {
return this._j.getValue();
}

@@ -29,8 +29,8 @@

return this._18;
return this._j;
};
Promise.prototype.getReason = function () {
if (this._83 === 3) {
return this._18.getReason();
if (this._i === 3) {
return this._j.getReason();
}

@@ -42,14 +42,14 @@

return this._18;
return this._j;
};
Promise.prototype.getState = function () {
if (this._83 === 3) {
return this._18.getState();
if (this._i === 3) {
return this._j.getState();
}
if (this._83 === -1 || this._83 === -2) {
if (this._i === -1 || this._i === -2) {
return 0;
}
return this._83;
return this._i;
};

@@ -56,0 +56,0 @@ };

@@ -61,12 +61,12 @@ 'use strict';

}
this._75 = 0;
this._83 = 0;
this._18 = null;
this._38 = null;
this._h = 0;
this._i = 0;
this._j = null;
this._k = null;
if (fn === noop) return;
doResolve(fn, this);
}
Promise._47 = null;
Promise._71 = null;
Promise._44 = noop;
Promise._l = null;
Promise._m = null;
Promise._n = noop;

@@ -90,20 +90,20 @@ Promise.prototype.then = function(onFulfilled, onRejected) {

function handle(self, deferred) {
while (self._83 === 3) {
self = self._18;
while (self._i === 3) {
self = self._j;
}
if (Promise._47) {
Promise._47(self);
if (Promise._l) {
Promise._l(self);
}
if (self._83 === 0) {
if (self._75 === 0) {
self._75 = 1;
self._38 = deferred;
if (self._i === 0) {
if (self._h === 0) {
self._h = 1;
self._k = deferred;
return;
}
if (self._75 === 1) {
self._75 = 2;
self._38 = [self._38, deferred];
if (self._h === 1) {
self._h = 2;
self._k = [self._k, deferred];
return;
}
self._38.push(deferred);
self._k.push(deferred);
return;

@@ -116,12 +116,12 @@ }

asap(function() {
var cb = self._83 === 1 ? deferred.onFulfilled : deferred.onRejected;
var cb = self._i === 1 ? deferred.onFulfilled : deferred.onRejected;
if (cb === null) {
if (self._83 === 1) {
resolve(deferred.promise, self._18);
if (self._i === 1) {
resolve(deferred.promise, self._j);
} else {
reject(deferred.promise, self._18);
reject(deferred.promise, self._j);
}
return;
}
var ret = tryCallOne(cb, self._18);
var ret = tryCallOne(cb, self._j);
if (ret === IS_ERROR) {

@@ -154,4 +154,4 @@ reject(deferred.promise, LAST_ERROR);

) {
self._83 = 3;
self._18 = newValue;
self._i = 3;
self._j = newValue;
finale(self);

@@ -164,4 +164,4 @@ return;

}
self._83 = 1;
self._18 = newValue;
self._i = 1;
self._j = newValue;
finale(self);

@@ -171,6 +171,6 @@ }

function reject(self, newValue) {
self._83 = 2;
self._18 = newValue;
if (Promise._71) {
Promise._71(self, newValue);
self._i = 2;
self._j = newValue;
if (Promise._m) {
Promise._m(self, newValue);
}

@@ -180,11 +180,11 @@ finale(self);

function finale(self) {
if (self._75 === 1) {
handle(self, self._38);
self._38 = null;
if (self._h === 1) {
handle(self, self._k);
self._k = null;
}
if (self._75 === 2) {
for (var i = 0; i < self._38.length; i++) {
handle(self, self._38[i]);
if (self._h === 2) {
for (var i = 0; i < self._k.length; i++) {
handle(self, self._k[i]);
}
self._38 = null;
self._k = null;
}

@@ -191,0 +191,0 @@ }

@@ -19,5 +19,5 @@ 'use strict';

function valuePromise(value) {
var p = new Promise(Promise._44);
p._83 = 1;
p._18 = value;
var p = new Promise(Promise._n);
p._i = 1;
p._j = value;
return p;

@@ -59,7 +59,7 @@ }

if (val instanceof Promise && val.then === Promise.prototype.then) {
while (val._83 === 3) {
val = val._18;
while (val._i === 3) {
val = val._j;
}
if (val._83 === 1) return res(i, val._18);
if (val._83 === 2) reject(val._18);
if (val._i === 1) return res(i, val._j);
if (val._i === 2) reject(val._j);
val.then(function (val) {

@@ -66,0 +66,0 @@ res(i, val);

@@ -6,3 +6,3 @@ 'use strict';

module.exports = Promise;
Promise.prototype['finally'] = function (f) {
Promise.prototype.finally = function (f) {
return this.then(function (value) {

@@ -9,0 +9,0 @@ return Promise.resolve(f()).then(function () {

@@ -15,4 +15,4 @@ 'use strict';

enabled = false;
Promise._47 = null;
Promise._71 = null;
Promise._l = null;
Promise._m = null;
}

@@ -28,23 +28,23 @@

var rejections = {};
Promise._47 = function (promise) {
Promise._l = function (promise) {
if (
promise._83 === 2 && // IS REJECTED
rejections[promise._56]
promise._i === 2 && // IS REJECTED
rejections[promise._o]
) {
if (rejections[promise._56].logged) {
onHandled(promise._56);
if (rejections[promise._o].logged) {
onHandled(promise._o);
} else {
clearTimeout(rejections[promise._56].timeout);
clearTimeout(rejections[promise._o].timeout);
}
delete rejections[promise._56];
delete rejections[promise._o];
}
};
Promise._71 = function (promise, err) {
if (promise._75 === 0) { // not yet handled
promise._56 = id++;
rejections[promise._56] = {
Promise._m = function (promise, err) {
if (promise._h === 0) { // not yet handled
promise._o = id++;
rejections[promise._o] = {
displayId: null,
error: err,
timeout: setTimeout(
onUnhandled.bind(null, promise._56),
onUnhandled.bind(null, promise._o),
// For reference errors and type errors, this almost always

@@ -51,0 +51,0 @@ // means the programmer made a mistake, so log them after just

@@ -20,4 +20,4 @@ 'use strict';

Promise.prototype.getValue = function () {
if (this._83 === 3) {
return this._18.getValue();
if (this._i === 3) {
return this._j.getValue();
}

@@ -29,8 +29,8 @@

return this._18;
return this._j;
};
Promise.prototype.getReason = function () {
if (this._83 === 3) {
return this._18.getReason();
if (this._i === 3) {
return this._j.getReason();
}

@@ -42,14 +42,14 @@

return this._18;
return this._j;
};
Promise.prototype.getState = function () {
if (this._83 === 3) {
return this._18.getState();
if (this._i === 3) {
return this._j.getState();
}
if (this._83 === -1 || this._83 === -2) {
if (this._i === -1 || this._i === -2) {
return 0;
}
return this._83;
return this._i;
};

@@ -56,0 +56,0 @@ };

{
"name": "promise",
"version": "8.0.1",
"version": "8.0.2",
"description": "Bare bones Promises/A+ implementation",

@@ -33,4 +33,4 @@ "main": "index.js",

"dependencies": {
"asap": "~2.0.3"
"asap": "~2.0.6"
}
}

@@ -59,3 +59,3 @@ <a href="https://promisesaplus.com/"><img src="https://promisesaplus.com/assets/logo-small.png" align="right" /></a>

If you need [domains](https://iojs.org/api/domain.html) support, you should instead use:
If you need [domains](https://nodejs.org/api/domain.html) support, you should instead use:

@@ -62,0 +62,0 @@ ```js

@@ -61,12 +61,12 @@ 'use strict';

}
this._75 = 0;
this._83 = 0;
this._18 = null;
this._38 = null;
this._h = 0;
this._i = 0;
this._j = null;
this._k = null;
if (fn === noop) return;
doResolve(fn, this);
}
Promise._47 = null;
Promise._71 = null;
Promise._44 = noop;
Promise._l = null;
Promise._m = null;
Promise._n = noop;

@@ -90,20 +90,20 @@ Promise.prototype.then = function(onFulfilled, onRejected) {

function handle(self, deferred) {
while (self._83 === 3) {
self = self._18;
while (self._i === 3) {
self = self._j;
}
if (Promise._47) {
Promise._47(self);
if (Promise._l) {
Promise._l(self);
}
if (self._83 === 0) {
if (self._75 === 0) {
self._75 = 1;
self._38 = deferred;
if (self._i === 0) {
if (self._h === 0) {
self._h = 1;
self._k = deferred;
return;
}
if (self._75 === 1) {
self._75 = 2;
self._38 = [self._38, deferred];
if (self._h === 1) {
self._h = 2;
self._k = [self._k, deferred];
return;
}
self._38.push(deferred);
self._k.push(deferred);
return;

@@ -116,12 +116,12 @@ }

setImmediate(function() {
var cb = self._83 === 1 ? deferred.onFulfilled : deferred.onRejected;
var cb = self._i === 1 ? deferred.onFulfilled : deferred.onRejected;
if (cb === null) {
if (self._83 === 1) {
resolve(deferred.promise, self._18);
if (self._i === 1) {
resolve(deferred.promise, self._j);
} else {
reject(deferred.promise, self._18);
reject(deferred.promise, self._j);
}
return;
}
var ret = tryCallOne(cb, self._18);
var ret = tryCallOne(cb, self._j);
if (ret === IS_ERROR) {

@@ -154,4 +154,4 @@ reject(deferred.promise, LAST_ERROR);

) {
self._83 = 3;
self._18 = newValue;
self._i = 3;
self._j = newValue;
finale(self);

@@ -164,4 +164,4 @@ return;

}
self._83 = 1;
self._18 = newValue;
self._i = 1;
self._j = newValue;
finale(self);

@@ -171,6 +171,6 @@ }

function reject(self, newValue) {
self._83 = 2;
self._18 = newValue;
if (Promise._71) {
Promise._71(self, newValue);
self._i = 2;
self._j = newValue;
if (Promise._m) {
Promise._m(self, newValue);
}

@@ -180,11 +180,11 @@ finale(self);

function finale(self) {
if (self._75 === 1) {
handle(self, self._38);
self._38 = null;
if (self._h === 1) {
handle(self, self._k);
self._k = null;
}
if (self._75 === 2) {
for (var i = 0; i < self._38.length; i++) {
handle(self, self._38[i]);
if (self._h === 2) {
for (var i = 0; i < self._k.length; i++) {
handle(self, self._k[i]);
}
self._38 = null;
self._k = null;
}

@@ -191,0 +191,0 @@ }

@@ -19,5 +19,5 @@ 'use strict';

function valuePromise(value) {
var p = new Promise(Promise._44);
p._83 = 1;
p._18 = value;
var p = new Promise(Promise._n);
p._i = 1;
p._j = value;
return p;

@@ -59,7 +59,7 @@ }

if (val instanceof Promise && val.then === Promise.prototype.then) {
while (val._83 === 3) {
val = val._18;
while (val._i === 3) {
val = val._j;
}
if (val._83 === 1) return res(i, val._18);
if (val._83 === 2) reject(val._18);
if (val._i === 1) return res(i, val._j);
if (val._i === 2) reject(val._j);
val.then(function (val) {

@@ -66,0 +66,0 @@ res(i, val);

@@ -6,3 +6,3 @@ 'use strict';

module.exports = Promise;
Promise.prototype['finally'] = function (f) {
Promise.prototype.finally = function (f) {
return this.then(function (value) {

@@ -9,0 +9,0 @@ return Promise.resolve(f()).then(function () {

@@ -15,4 +15,4 @@ 'use strict';

enabled = false;
Promise._47 = null;
Promise._71 = null;
Promise._l = null;
Promise._m = null;
}

@@ -28,23 +28,23 @@

var rejections = {};
Promise._47 = function (promise) {
Promise._l = function (promise) {
if (
promise._83 === 2 && // IS REJECTED
rejections[promise._56]
promise._i === 2 && // IS REJECTED
rejections[promise._o]
) {
if (rejections[promise._56].logged) {
onHandled(promise._56);
if (rejections[promise._o].logged) {
onHandled(promise._o);
} else {
clearTimeout(rejections[promise._56].timeout);
clearTimeout(rejections[promise._o].timeout);
}
delete rejections[promise._56];
delete rejections[promise._o];
}
};
Promise._71 = function (promise, err) {
if (promise._75 === 0) { // not yet handled
promise._56 = id++;
rejections[promise._56] = {
Promise._m = function (promise, err) {
if (promise._h === 0) { // not yet handled
promise._o = id++;
rejections[promise._o] = {
displayId: null,
error: err,
timeout: setTimeout(
onUnhandled.bind(null, promise._56),
onUnhandled.bind(null, promise._o),
// For reference errors and type errors, this almost always

@@ -51,0 +51,0 @@ // means the programmer made a mistake, so log them after just

@@ -20,4 +20,4 @@ 'use strict';

Promise.prototype.getValue = function () {
if (this._83 === 3) {
return this._18.getValue();
if (this._i === 3) {
return this._j.getValue();
}

@@ -29,8 +29,8 @@

return this._18;
return this._j;
};
Promise.prototype.getReason = function () {
if (this._83 === 3) {
return this._18.getReason();
if (this._i === 3) {
return this._j.getReason();
}

@@ -42,14 +42,14 @@

return this._18;
return this._j;
};
Promise.prototype.getState = function () {
if (this._83 === 3) {
return this._18.getState();
if (this._i === 3) {
return this._j.getState();
}
if (this._83 === -1 || this._83 === -2) {
if (this._i === -1 || this._i === -2) {
return 0;
}
return this._83;
return this._i;
};

@@ -56,0 +56,0 @@ };

@@ -6,3 +6,3 @@ 'use strict';

module.exports = Promise;
Promise.prototype['finally'] = function (f) {
Promise.prototype.finally = function (f) {
return this.then(function (value) {

@@ -9,0 +9,0 @@ return Promise.resolve(f()).then(function () {

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