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

mutable-promise

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mutable-promise - npm Package Compare versions

Comparing version 1.1.8 to 1.1.9

85

dist/index.esm.js

@@ -1,53 +0,4 @@

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
const isPromiseLike = (value) => (value && "object" === typeof value && "function" === typeof value.then);
class MutablePromise extends Promise {
constructor(executor) {
let rs;
let rj;
const fn = (_rs, _rj) => { rs = _rs; rj = _rj; };
super(fn);
this._s = "pending";
this.resolve = (value) => {
if (this.isPending) {
if (isPromiseLike(value)) {
this.task = value;
}
else {
this._s = "fulfilled";
rs(value);
}
}
};
this.reject = (reason) => {
if (this.isPending) {
this._s = "rejected";
rj(reason);
}
};
this.task = executor;
}
_s;
get status() { return this._s; }

@@ -57,2 +8,3 @@ get isPending() { return "pending" === this._s; }

get isRejected() { return "rejected" === this._s; }
_task;
get task() { return this._task; }

@@ -70,5 +22,5 @@ set task(value) {

if (p) {
(() => __awaiter(this, void 0, void 0, function* () {
(async () => {
try {
const ret = yield p;
const ret = await p;
// make sure task not change

@@ -85,6 +37,33 @@ if (value === this._task) {

}
}))();
})();
}
}
get isEmpty() { return null == this._task; }
resolve;
reject;
constructor(executor) {
let rs;
let rj;
const fn = (_rs, _rj) => { rs = _rs; rj = _rj; };
super(fn);
this._s = "pending";
this.resolve = (value) => {
if (this.isPending) {
if (isPromiseLike(value)) {
this.task = value;
}
else {
this._s = "fulfilled";
rs(value);
}
}
};
this.reject = (reason) => {
if (this.isPending) {
this._s = "rejected";
rj(reason);
}
};
this.task = executor;
}
}

@@ -91,0 +70,0 @@

@@ -1,2 +0,2 @@

function t(t,e,s,i){return new(s||(s=Promise))((function(n,r){function o(t){try{h(i.next(t))}catch(t){r(t)}}function c(t){try{h(i.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(o,c)}h((i=i.apply(t,e||[])).next())}))}const e=t=>t&&"object"==typeof t&&"function"==typeof t.then;class s extends Promise{constructor(t){let s,i;super(((t,e)=>{s=t,i=e})),this._s="pending",this.resolve=t=>{this.isPending&&(e(t)?this.task=t:(this._s="fulfilled",s(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}get status(){return this._s}get isPending(){return"pending"===this._s}get isFulfilled(){return"fulfilled"===this._s}get isRejected(){return"rejected"===this._s}get task(){return this._task}set task(s){let i;this._task=s,e(s)?i=s:"function"==typeof s&&(i=new Promise(s)),i&&(()=>{t(this,void 0,void 0,(function*(){try{const t=yield i;s===this._task&&this.resolve(t)}catch(t){s===this._task&&this.reject(t)}}))})()}get isEmpty(){return null==this._task}}export{s as default};
const t=t=>t&&"object"==typeof t&&"function"==typeof t.then;class s extends Promise{_s;get status(){return this._s}get isPending(){return"pending"===this._s}get isFulfilled(){return"fulfilled"===this._s}get isRejected(){return"rejected"===this._s}_task;get task(){return this._task}set task(s){let e;this._task=s,t(s)?e=s:"function"==typeof s&&(e=new Promise(s)),e&&(async()=>{try{const t=await e;s===this._task&&this.resolve(t)}catch(t){s===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}resolve;reject;constructor(s){let e,i;super(((t,s)=>{e=t,i=s})),this._s="pending",this.resolve=s=>{this.isPending&&(t(s)?this.task=s:(this._s="fulfilled",e(s)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=s}}export{s as default};
//# sourceMappingURL=index.min.mjs.map

@@ -7,54 +7,5 @@ (function (global, factory) {

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
const isPromiseLike = (value) => (value && "object" === typeof value && "function" === typeof value.then);
class MutablePromise extends Promise {
constructor(executor) {
let rs;
let rj;
const fn = (_rs, _rj) => { rs = _rs; rj = _rj; };
super(fn);
this._s = "pending";
this.resolve = (value) => {
if (this.isPending) {
if (isPromiseLike(value)) {
this.task = value;
}
else {
this._s = "fulfilled";
rs(value);
}
}
};
this.reject = (reason) => {
if (this.isPending) {
this._s = "rejected";
rj(reason);
}
};
this.task = executor;
}
_s;
get status() { return this._s; }

@@ -64,2 +15,3 @@ get isPending() { return "pending" === this._s; }

get isRejected() { return "rejected" === this._s; }
_task;
get task() { return this._task; }

@@ -77,5 +29,5 @@ set task(value) {

if (p) {
(() => __awaiter(this, void 0, void 0, function* () {
(async () => {
try {
const ret = yield p;
const ret = await p;
// make sure task not change

@@ -92,6 +44,33 @@ if (value === this._task) {

}
}))();
})();
}
}
get isEmpty() { return null == this._task; }
resolve;
reject;
constructor(executor) {
let rs;
let rj;
const fn = (_rs, _rj) => { rs = _rs; rj = _rj; };
super(fn);
this._s = "pending";
this.resolve = (value) => {
if (this.isPending) {
if (isPromiseLike(value)) {
this.task = value;
}
else {
this._s = "fulfilled";
rs(value);
}
}
};
this.reject = (reason) => {
if (this.isPending) {
this._s = "rejected";
rj(reason);
}
};
this.task = executor;
}
}

@@ -98,0 +77,0 @@

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).MutablePromise=e()}(this,(function(){"use strict";function t(t,e,s,i){return new(s||(s=Promise))((function(n,o){function r(t){try{c(i.next(t))}catch(t){o(t)}}function u(t){try{c(i.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(r,u)}c((i=i.apply(t,e||[])).next())}))}const e=t=>t&&"object"==typeof t&&"function"==typeof t.then;return class extends Promise{constructor(t){let s,i;super(((t,e)=>{s=t,i=e})),this._s="pending",this.resolve=t=>{this.isPending&&(e(t)?this.task=t:(this._s="fulfilled",s(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}get status(){return this._s}get isPending(){return"pending"===this._s}get isFulfilled(){return"fulfilled"===this._s}get isRejected(){return"rejected"===this._s}get task(){return this._task}set task(s){let i;this._task=s,e(s)?i=s:"function"==typeof s&&(i=new Promise(s)),i&&(()=>{t(this,void 0,void 0,(function*(){try{const t=yield i;s===this._task&&this.resolve(t)}catch(t){s===this._task&&this.reject(t)}}))})()}get isEmpty(){return null==this._task}}}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).MutablePromise=e()}(this,(function(){"use strict";const t=t=>t&&"object"==typeof t&&"function"==typeof t.then;return class extends Promise{_s;get status(){return this._s}get isPending(){return"pending"===this._s}get isFulfilled(){return"fulfilled"===this._s}get isRejected(){return"rejected"===this._s}_task;get task(){return this._task}set task(e){let s;this._task=e,t(e)?s=e:"function"==typeof e&&(s=new Promise(e)),s&&(async()=>{try{const t=await s;e===this._task&&this.resolve(t)}catch(t){e===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}resolve;reject;constructor(e){let s,i;super(((t,e)=>{s=t,i=e})),this._s="pending",this.resolve=e=>{this.isPending&&(t(e)?this.task=e:(this._s="fulfilled",s(e)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=e}}}));
//# sourceMappingURL=index.min.js.map
{
"name": "mutable-promise",
"version": "1.1.8",
"version": "1.1.9",
"description": "Wrapper for Promise. Resolvable, rejectable, redirectable.",

@@ -5,0 +5,0 @@ "files": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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