Gathering detailed insights and metrics for p-reflect
Gathering detailed insights and metrics for p-reflect
Gathering detailed insights and metrics for p-reflect
Gathering detailed insights and metrics for p-reflect
Make a promise always fulfill with its actual fulfillment value or rejection reason
npm install p-reflect
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.4
Supply Chain
99.4
Quality
75.4
Maintenance
100
Vulnerability
100
License
JavaScript (65.14%)
TypeScript (34.86%)
Total Downloads
103,793,500
Last Day
10,293
Last Week
487,154
Last Month
2,106,191
Last Year
28,383,293
53 Stars
13 Commits
8 Forks
7 Watching
1 Branches
5 Contributors
Latest Version
3.1.0
Package Id
p-reflect@3.1.0
Unpacked Size
6.95 kB
Size
2.57 kB
File Count
5
NPM Version
8.3.2
Node Version
14.19.3
Cumulative downloads
Total Downloads
Last day
-43.2%
10,293
Compared to previous day
Last week
-7.8%
487,154
Compared to previous week
Last month
-9.8%
2,106,191
Compared to previous month
Last year
-14.7%
28,383,293
Compared to previous year
Make a promise always fulfill with its actual fulfillment value or rejection reason
Useful when you want a promise to fulfill no matter what and would rather handle the actual state afterwards.
$ npm install p-reflect
Here, Promise.all
would normally fail early because one of the promises rejects, but by using p-reflect
, we can ignore the rejection and handle it later on.
1import pReflect from 'p-reflect'; 2 3const promises = [ 4 getPromise(), 5 getPromiseThatRejects(), 6 getPromise() 7]; 8 9const results = await Promise.all(promises.map(pReflect)); 10 11console.log(results); 12/* 13[ 14 { 15 status: 'fulfilled', 16 value: '🦄' 17 isFulfilled: true, 18 isRejected: false 19 }, 20 { 21 status: 'rejected', 22 reason: [Error: 👹] 23 isFulfilled: false, 24 isRejected: true 25 }, 26 { 27 status: 'fulfilled', 28 value: '🐴' 29 isFulfilled: true, 30 isRejected: false 31 } 32] 33*/ 34 35const resolvedString = results 36 .filter(result => result.isFulfilled) 37 .map(result => result.value) 38 .join(''); 39 40console.log(resolvedString); 41//=> '🦄🐴'
The above is just an example. Use p-settle
if you need exactly that.
Returns a Promise<Object>
.
The object has the following properties:
status
('fulfilled'
or 'rejected'
, depending on how the promise resolved)value
or reason
(Depending on whether the promise fulfilled or rejected)isFulfilled
isRejected
Type: Promise
A promise to reflect upon.
This is a type guard for TypeScript users.
Returns true
if the object has the property value
, false
otherwise.
This is useful since await pReflect(promise)
always returns a PromiseResult
. This function can be used to determine whether PromiseResult
is PromiseFulfilledResult
or PromiseRejectedResult
.
This is a workaround for microsoft/TypeScript#32399
This is a type guard for TypeScript users.
Returns true
if the object has the property reason
, false
otherwise.
This is useful since await pReflect(promise)
always returns a PromiseResult
. This function can be used to determine whether PromiseResult
is PromiseRejectedResult
or PromiseFulfilledResult
.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 5/13 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-12-16
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