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

cancelable-promise

Package Overview
Dependencies
Maintainers
3
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.4.0 to 2.4.1

yarn-error.log

5

CancelablePromise.js

@@ -68,6 +68,9 @@ const handleCallback = (resolve, reject, callback, r) => {

cancel() {
cancel(errorCallback) {
this._canceled = true;
if (errorCallback) {
this._promise.catch(errorCallback);
}
return this;
}
}

@@ -260,2 +260,29 @@ import {

});
it('should call cancel function if rejected after a cancel', (done) => {
const promise = new CancelablePromise((resolve, reject) => {
reject(new Error('test456'));
});
let cancelCalled = false;
let catchCalled = false;
promise.cancel((err) => {
cancelCalled = true;
});
promise.catch((err) => {
catchCalled = true;
})
const end = () => {
let hasFailed = false;
if (catchCalled) {
hasFailed = 'Promise should NOT call catch when rejected after a cancel';
} else if (!cancelCalled) {
hasFailed = 'Promise should call cancel error callback on a rejection';
}
done(!!hasFailed ? new Error(hasFailed) : undefined);
};
setTimeout(end, 0);
})
});

@@ -92,4 +92,7 @@ "use strict";

key: "cancel",
value: function cancel() {
value: function cancel(errorCallback) {
this._canceled = true;
if (errorCallback) {
this._promise.catch(errorCallback);
}
return this;

@@ -96,0 +99,0 @@ }

2

package.json
{
"name": "cancelable-promise",
"version": "2.4.0",
"version": "2.4.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