Gathering detailed insights and metrics for @ybq/p-cancelable
Gathering detailed insights and metrics for @ybq/p-cancelable
npm install @ybq/p-cancelable
Typescript
Module System
Node Version
NPM Version
69.4
Supply Chain
92.6
Quality
75
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
549
Last Day
2
Last Week
5
Last Month
15
Last Year
63
MIT License
6 Commits
1 Branches
1 Contributors
Updated on Aug 24, 2017
Minified
Minified + Gzipped
Latest Version
1.0.0
Package Id
@ybq/p-cancelable@1.0.0
Size
2.83 kB
NPM Version
5.3.0
Node Version
8.1.2
Cumulative downloads
Total Downloads
Last Day
0%
2
Compared to previous day
Last Week
66.7%
5
Compared to previous week
Last Month
114.3%
15
Compared to previous month
Last Year
-12.5%
63
Compared to previous year
1
Promise that can be canceled, learned from sindresorhus/p-cancelable.
The difference from sindresorhus version is that CancelablePromise in this lib is not a subclass of Promise.
$ npm i @ybq/p-cancelable
const PCancelable = require('@ybq/p-cancelable');
const cancelablePromise = new PCancelable((onCancel, resolve, reject) => {
const worker = new SomeLongRunningOperation();
onCancel(() => {
worker.close();
});
worker.on('finish', resolve);
worker.on('error', reject);
});
cancelablePromise
.then(value => {
console.log('Operation finished successfully:', value);
})
.catch(reason => {
if (cancelablePromise.canceled) {
// Handle the cancelation here
console.log('Operation was canceled');
return;
}
throw reason;
});
// Cancel the operation after 10 seconds
setTimeout(() => {
cancelablePromise.cancel();
}, 10000);
Same as the Promise
constructor, but with a prepended onCancel
parameter in executor
.
PCancelable
is a subclass of Promise
.
Type: Function
Accepts a function that is called when the promise is canceled.
You're not required to call this function.
Type: Function
Cancel the promise. The cancellation is synchronous.
Calling it after the promise has settled or multiple times does nothing.
Type: boolean
Whether the promise is canceled.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/6 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
71 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-02-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More