Socket
Socket
Sign inDemoInstall

cancelable-promise

Package Overview
Dependencies
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cancelable-promise - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

8

CancelablePromise.js

@@ -26,6 +26,7 @@ export default class CancelablePromise {

p.cancel();
resolve();
}
if (success && !this._canceled) {
resolve(success(r));
} else {
resolve(r);
}

@@ -35,6 +36,7 @@ }, (r) => {

p.cancel();
reject();
}
if (error && !this._canceled) {
reject(error(r));
resolve(error(r));
} else {
resolve(r);
}

@@ -41,0 +43,0 @@ });

@@ -16,12 +16,14 @@ import { assert, expect } from 'chai';

const promise = new CancelablePromise((resolve, reject) => {
reject('nop');
reject('eagle');
});
promise.then(() => {
const promise2 = promise.then(() => {
done(new Error('Success callback should not be executed'));
}, (reason) => {
expect(reason).to.be.equal('nop');
expect(reason).to.be.equal('eagle');
end();
return reason;
}).catch((reason) => {
expect(reason).to.be.equal('nop');
return 'rabbit';
});
promise2.then((reason) => {
expect(reason).to.be.equal('rabbit');
end();

@@ -46,3 +48,3 @@ });

it('should works like a tree', (done) => {
it('should work like a tree', (done) => {
const end = createEnd(done, 2);

@@ -72,3 +74,3 @@ const promise = new CancelablePromise((resolve, reject) => {

it('should works also when then is added in a then', (done) => {
it('should work also when then is added in a then', (done) => {
const end = createEnd(done, 2);

@@ -93,2 +95,21 @@ const promise = new CancelablePromise((resolve, reject) => {

it('should work when empty or partial then', (done) => {
const end = createEnd(done, 2);
const promise = new CancelablePromise((resolve, reject) => {
resolve('test123');
});
const promise2 = promise.then();
promise2.then((value) => {
console.log(value);
expect(value).to.be.equal('test123');
end();
return 'fox';
}).then((value) => {
console.log(value);
expect(value).to.be.equal('fox');
end();
});
});
it('should not execute callbacks if canceled', (done) => {

@@ -95,0 +116,0 @@ let hasFailed = false;

@@ -53,6 +53,7 @@ "use strict";

p.cancel();
resolve();
}
if (success && !_this._canceled) {
resolve(success(r));
} else {
resolve(r);
}

@@ -62,6 +63,7 @@ }, function (r) {

p.cancel();
reject();
}
if (error && !_this._canceled) {
reject(error(r));
resolve(error(r));
} else {
resolve(r);
}

@@ -68,0 +70,0 @@ });

{
"name": "cancelable-promise",
"version": "2.1.0",
"version": "2.1.1",
"description": "A simple cancelable promise",

@@ -5,0 +5,0 @@ "main": "dist/CancelablePromise.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