Gathering detailed insights and metrics for @byungi/p-cancel
Gathering detailed insights and metrics for @byungi/p-cancel
npm install @byungi/p-cancel
Typescript
Module System
Min. Node Version
Node Version
NPM Version
68.1
Supply Chain
79.9
Quality
75.1
Maintenance
100
Vulnerability
100
License
TypeScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
6,274
Last Day
5
Last Week
9
Last Month
48
Last Year
842
3 Stars
101 Commits
1 Forks
3 Watchers
2 Branches
1 Contributors
Updated on Nov 21, 2021
Minified
Minified + Gzipped
Latest Version
0.2.1
Package Id
@byungi/p-cancel@0.2.1
Unpacked Size
5.48 kB
Size
1.98 kB
File Count
4
NPM Version
lerna/3.20.1/node@v13.3.0+x64 (win32)
Node Version
13.3.0
Cumulative downloads
Total Downloads
Last Day
150%
5
Compared to previous day
Last Week
-60.9%
9
Compared to previous week
Last Month
20%
48
Compared to previous month
Last Year
-57.5%
842
Compared to previous year
2
A cancelable promise.
1import PCancel, {CancelError} from '@byungi/p-cancel' 2 3const requestPromise = new PCancel((resolve, reject, onCancel) => { 4 var xhr = new XMLHttpRequest(); 5 xhr.on('load', resolve); 6 xhr.on('error', reject); 7 xhr.open('GET', 'http://delay/500ms/call', true); 8 xhr.send(null); 9 10 onCancel(()=> xhr.abort()) 11}) 12 13console.log(requestPromise.isCanceled) // => false 14 15setTimeout(()=> { 16 requestPromise.cancel() // => After 100ms, xhr is aborted. 17}, 100) 18 19requestPromise.catch(err => { 20 console.log(err.isCanceled) // => true 21 console.log(err instanceof CancelError) // => true 22 console.log(requestPromise.isCanceled) // => true 23})
PCancel
is a promise implementation. Same as promise creation except for onCancel
. onCancel
receives a function to operate on cancel()
.
1const promise = new PCancel((resolve, reject, onCancel) => {
2 const timerId = setTimeout(lazyJob, 1000)
3 onCancel(()=> clearTimeout(timerId))
4})
Execute the cancel operation added with onCancel
and throw a CancelError
.
Returns whether the promise is canceled.
Similar to then
but can propagate cancel
to the upper promise.
1const handleWithRequestPromise = requestPromise.pipe(response => { 2 handleResponse(response) 3}) 4 5handleWithRequestPromise.cancel() // => xhr is aborted
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
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