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.3 to 8.1.0

.github/FUNDING.yml

78

domains/core.js

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

}
this._h = 0;
this._i = 0;
this._j = null;
this._k = null;
this._U = 0;
this._V = 0;
this._W = null;
this._X = null;
if (fn === noop) return;
doResolve(fn, this);
}
Promise._l = null;
Promise._m = null;
Promise._n = noop;
Promise._Y = null;
Promise._Z = null;
Promise._0 = noop;

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

function handle(self, deferred) {
while (self._i === 3) {
self = self._j;
while (self._V === 3) {
self = self._W;
}
if (Promise._l) {
Promise._l(self);
if (Promise._Y) {
Promise._Y(self);
}
if (self._i === 0) {
if (self._h === 0) {
self._h = 1;
self._k = deferred;
if (self._V === 0) {
if (self._U === 0) {
self._U = 1;
self._X = deferred;
return;
}
if (self._h === 1) {
self._h = 2;
self._k = [self._k, deferred];
if (self._U === 1) {
self._U = 2;
self._X = [self._X, deferred];
return;
}
self._k.push(deferred);
self._X.push(deferred);
return;

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

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

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

) {
self._i = 3;
self._j = newValue;
self._V = 3;
self._W = newValue;
finale(self);

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

}
self._i = 1;
self._j = newValue;
self._V = 1;
self._W = newValue;
finale(self);

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

function reject(self, newValue) {
self._i = 2;
self._j = newValue;
if (Promise._m) {
Promise._m(self, newValue);
self._V = 2;
self._W = newValue;
if (Promise._Z) {
Promise._Z(self, newValue);
}

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

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

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

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

function valuePromise(value) {
var p = new Promise(Promise._n);
p._i = 1;
p._j = value;
var p = new Promise(Promise._0);
p._V = 1;
p._W = value;
return p;

@@ -50,4 +50,16 @@ }

var iterableToArray = function (iterable) {
if (typeof Array.from === 'function') {
// ES2015+, iterables exist
iterableToArray = Array.from;
return Array.from(iterable);
}
// ES5, only arrays and array-likes exist
iterableToArray = function (x) { return Array.prototype.slice.call(x); };
return Array.prototype.slice.call(iterable);
}
Promise.all = function (arr) {
var args = Array.prototype.slice.call(arr);
var args = iterableToArray(arr);

@@ -60,7 +72,7 @@ return new Promise(function (resolve, reject) {

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

@@ -100,3 +112,3 @@ res(i, val);

return new Promise(function (resolve, reject) {
values.forEach(function(value){
iterableToArray(values).forEach(function(value){
Promise.resolve(value).then(resolve, reject);

@@ -103,0 +115,0 @@ });

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

enabled = false;
Promise._l = null;
Promise._m = null;
Promise._Y = null;
Promise._Z = null;
}

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

var rejections = {};
Promise._l = function (promise) {
Promise._Y = function (promise) {
if (
promise._i === 2 && // IS REJECTED
rejections[promise._o]
promise._V === 2 && // IS REJECTED
rejections[promise._1]
) {
if (rejections[promise._o].logged) {
onHandled(promise._o);
if (rejections[promise._1].logged) {
onHandled(promise._1);
} else {
clearTimeout(rejections[promise._o].timeout);
clearTimeout(rejections[promise._1].timeout);
}
delete rejections[promise._o];
delete rejections[promise._1];
}
};
Promise._m = function (promise, err) {
if (promise._h === 0) { // not yet handled
promise._o = id++;
rejections[promise._o] = {
Promise._Z = function (promise, err) {
if (promise._U === 0) { // not yet handled
promise._1 = id++;
rejections[promise._1] = {
displayId: null,
error: err,
timeout: setTimeout(
onUnhandled.bind(null, promise._o),
onUnhandled.bind(null, promise._1),
// 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._i === 3) {
return this._j.getValue();
if (this._V === 3) {
return this._W.getValue();
}

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

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

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

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

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

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

}
this._h = 0;
this._i = 0;
this._j = null;
this._k = null;
this._U = 0;
this._V = 0;
this._W = null;
this._X = null;
if (fn === noop) return;
doResolve(fn, this);
}
Promise._l = null;
Promise._m = null;
Promise._n = noop;
Promise._Y = null;
Promise._Z = null;
Promise._0 = noop;

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

function handle(self, deferred) {
while (self._i === 3) {
self = self._j;
while (self._V === 3) {
self = self._W;
}
if (Promise._l) {
Promise._l(self);
if (Promise._Y) {
Promise._Y(self);
}
if (self._i === 0) {
if (self._h === 0) {
self._h = 1;
self._k = deferred;
if (self._V === 0) {
if (self._U === 0) {
self._U = 1;
self._X = deferred;
return;
}
if (self._h === 1) {
self._h = 2;
self._k = [self._k, deferred];
if (self._U === 1) {
self._U = 2;
self._X = [self._X, deferred];
return;
}
self._k.push(deferred);
self._X.push(deferred);
return;

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

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

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

) {
self._i = 3;
self._j = newValue;
self._V = 3;
self._W = newValue;
finale(self);

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

}
self._i = 1;
self._j = newValue;
self._V = 1;
self._W = newValue;
finale(self);

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

function reject(self, newValue) {
self._i = 2;
self._j = newValue;
if (Promise._m) {
Promise._m(self, newValue);
self._V = 2;
self._W = newValue;
if (Promise._Z) {
Promise._Z(self, newValue);
}

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

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

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

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

function valuePromise(value) {
var p = new Promise(Promise._n);
p._i = 1;
p._j = value;
var p = new Promise(Promise._0);
p._V = 1;
p._W = value;
return p;

@@ -50,4 +50,16 @@ }

var iterableToArray = function (iterable) {
if (typeof Array.from === 'function') {
// ES2015+, iterables exist
iterableToArray = Array.from;
return Array.from(iterable);
}
// ES5, only arrays and array-likes exist
iterableToArray = function (x) { return Array.prototype.slice.call(x); };
return Array.prototype.slice.call(iterable);
}
Promise.all = function (arr) {
var args = Array.prototype.slice.call(arr);
var args = iterableToArray(arr);

@@ -60,7 +72,7 @@ return new Promise(function (resolve, reject) {

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

@@ -100,3 +112,3 @@ res(i, val);

return new Promise(function (resolve, reject) {
values.forEach(function(value){
iterableToArray(values).forEach(function(value){
Promise.resolve(value).then(resolve, reject);

@@ -103,0 +115,0 @@ });

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

enabled = false;
Promise._l = null;
Promise._m = null;
Promise._Y = null;
Promise._Z = null;
}

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

var rejections = {};
Promise._l = function (promise) {
Promise._Y = function (promise) {
if (
promise._i === 2 && // IS REJECTED
rejections[promise._o]
promise._V === 2 && // IS REJECTED
rejections[promise._1]
) {
if (rejections[promise._o].logged) {
onHandled(promise._o);
if (rejections[promise._1].logged) {
onHandled(promise._1);
} else {
clearTimeout(rejections[promise._o].timeout);
clearTimeout(rejections[promise._1].timeout);
}
delete rejections[promise._o];
delete rejections[promise._1];
}
};
Promise._m = function (promise, err) {
if (promise._h === 0) { // not yet handled
promise._o = id++;
rejections[promise._o] = {
Promise._Z = function (promise, err) {
if (promise._U === 0) { // not yet handled
promise._1 = id++;
rejections[promise._1] = {
displayId: null,
error: err,
timeout: setTimeout(
onUnhandled.bind(null, promise._o),
onUnhandled.bind(null, promise._1),
// 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._i === 3) {
return this._j.getValue();
if (this._V === 3) {
return this._W.getValue();
}

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

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

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

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

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

{
"name": "promise",
"version": "8.0.3",
"version": "8.1.0",
"description": "Bare bones Promises/A+ implementation",

@@ -5,0 +5,0 @@ "main": "index.js",

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

- allRejections (`boolean`) - track all exceptions, not just reference errors and type errors. Note that this has a high probability of resulting in false positives if your code loads data optimisticly
- allRejections (`boolean`) - track all exceptions, not just reference errors and type errors. Note that this has a high probability of resulting in false positives if your code loads data optimistically
- whitelist (`Array<ErrorConstructor>`) - this defaults to `[ReferenceError, TypeError]` but you can override it with your own list of error constructors to track.

@@ -112,2 +112,4 @@ - `onUnhandled(id, error)` and `onHandled(id, error)` - you can use these to provide your own customised display for errors. Note that if possible you should indicate that the error was a false positive if `onHandled` is called. `onHandled` is only called if `onUnhandled` has already been called.

Detailed API reference docs are available at https://www.promisejs.org/api/.
Before all examples, you will need:

@@ -153,2 +155,19 @@

#### Promise.race(array)
Returns a promise that resolves or rejects with the result of the first promise to resolve/reject, e.g.
```js
var rejected = Promise.reject(new Error('Whatever'));
var fulfilled = new Promise(function (resolve) {
setTimeout(() => resolve('success'), 500);
});
var race = Promise.race([rejected, fulfilled]);
// => immediately rejected with `new Error('Whatever')`
var success = Promise.resolve('immediate success');
var first = Promise.race([success, fulfilled]);
// => immediately succeeds with `immediate success`
```
#### Promise.denodeify(fn)

@@ -232,4 +251,10 @@

## Enterprise Support
Available as part of the Tidelift Subscription
The maintainers of promise and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-promise?utm_source=npm-promise&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
## License
MIT

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

}
this._h = 0;
this._i = 0;
this._j = null;
this._k = null;
this._U = 0;
this._V = 0;
this._W = null;
this._X = null;
if (fn === noop) return;
doResolve(fn, this);
}
Promise._l = null;
Promise._m = null;
Promise._n = noop;
Promise._Y = null;
Promise._Z = null;
Promise._0 = noop;

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

function handle(self, deferred) {
while (self._i === 3) {
self = self._j;
while (self._V === 3) {
self = self._W;
}
if (Promise._l) {
Promise._l(self);
if (Promise._Y) {
Promise._Y(self);
}
if (self._i === 0) {
if (self._h === 0) {
self._h = 1;
self._k = deferred;
if (self._V === 0) {
if (self._U === 0) {
self._U = 1;
self._X = deferred;
return;
}
if (self._h === 1) {
self._h = 2;
self._k = [self._k, deferred];
if (self._U === 1) {
self._U = 2;
self._X = [self._X, deferred];
return;
}
self._k.push(deferred);
self._X.push(deferred);
return;

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

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

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

) {
self._i = 3;
self._j = newValue;
self._V = 3;
self._W = newValue;
finale(self);

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

}
self._i = 1;
self._j = newValue;
self._V = 1;
self._W = newValue;
finale(self);

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

function reject(self, newValue) {
self._i = 2;
self._j = newValue;
if (Promise._m) {
Promise._m(self, newValue);
self._V = 2;
self._W = newValue;
if (Promise._Z) {
Promise._Z(self, newValue);
}

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

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

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

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

function valuePromise(value) {
var p = new Promise(Promise._n);
p._i = 1;
p._j = value;
var p = new Promise(Promise._0);
p._V = 1;
p._W = value;
return p;

@@ -50,4 +50,16 @@ }

var iterableToArray = function (iterable) {
if (typeof Array.from === 'function') {
// ES2015+, iterables exist
iterableToArray = Array.from;
return Array.from(iterable);
}
// ES5, only arrays and array-likes exist
iterableToArray = function (x) { return Array.prototype.slice.call(x); };
return Array.prototype.slice.call(iterable);
}
Promise.all = function (arr) {
var args = Array.prototype.slice.call(arr);
var args = iterableToArray(arr);

@@ -60,7 +72,7 @@ return new Promise(function (resolve, reject) {

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

@@ -100,3 +112,3 @@ res(i, val);

return new Promise(function (resolve, reject) {
values.forEach(function(value){
iterableToArray(values).forEach(function(value){
Promise.resolve(value).then(resolve, reject);

@@ -103,0 +115,0 @@ });

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

enabled = false;
Promise._l = null;
Promise._m = null;
Promise._Y = null;
Promise._Z = null;
}

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

var rejections = {};
Promise._l = function (promise) {
Promise._Y = function (promise) {
if (
promise._i === 2 && // IS REJECTED
rejections[promise._o]
promise._V === 2 && // IS REJECTED
rejections[promise._1]
) {
if (rejections[promise._o].logged) {
onHandled(promise._o);
if (rejections[promise._1].logged) {
onHandled(promise._1);
} else {
clearTimeout(rejections[promise._o].timeout);
clearTimeout(rejections[promise._1].timeout);
}
delete rejections[promise._o];
delete rejections[promise._1];
}
};
Promise._m = function (promise, err) {
if (promise._h === 0) { // not yet handled
promise._o = id++;
rejections[promise._o] = {
Promise._Z = function (promise, err) {
if (promise._U === 0) { // not yet handled
promise._1 = id++;
rejections[promise._1] = {
displayId: null,
error: err,
timeout: setTimeout(
onUnhandled.bind(null, promise._o),
onUnhandled.bind(null, promise._1),
// 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._i === 3) {
return this._j.getValue();
if (this._V === 3) {
return this._W.getValue();
}

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

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

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

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

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

@@ -49,4 +49,16 @@ 'use strict';

var iterableToArray = function (iterable) {
if (typeof Array.from === 'function') {
// ES2015+, iterables exist
iterableToArray = Array.from;
return Array.from(iterable);
}
// ES5, only arrays and array-likes exist
iterableToArray = function (x) { return Array.prototype.slice.call(x); };
return Array.prototype.slice.call(iterable);
}
Promise.all = function (arr) {
var args = Array.prototype.slice.call(arr);
var args = iterableToArray(arr);

@@ -98,3 +110,3 @@ return new Promise(function (resolve, reject) {

return new Promise(function (resolve, reject) {
values.forEach(function(value){
iterableToArray(values).forEach(function(value){
Promise.resolve(value).then(resolve, reject);

@@ -101,0 +113,0 @@ });

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