Gathering detailed insights and metrics for await-to-js
Gathering detailed insights and metrics for await-to-js
Gathering detailed insights and metrics for await-to-js
Gathering detailed insights and metrics for await-to-js
npm install await-to-js
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (80.66%)
JavaScript (19.34%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
3,324 Stars
43 Commits
155 Forks
21 Watchers
3 Branches
11 Contributors
Updated on Jul 08, 2025
Latest Version
3.0.0
Package Id
await-to-js@3.0.0
Size
396.66 kB
NPM Version
7.6.0
Node Version
15.11.0
Published on
Mar 09, 2021
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
26
Async await wrapper for easy error handling
You need to use Node 7.6 (or later) or an ES7 transpiler in order to use async/await functionality. You can use babel or typescript for that.
1npm i await-to-js --save
1import to from 'await-to-js'; 2// If you use CommonJS (i.e NodeJS environment), it should be: 3// const to = require('await-to-js').default; 4 5async function asyncTaskWithCb(cb) { 6 let err, user, savedTask, notification; 7 8 [ err, user ] = await to(UserModel.findById(1)); 9 if(!user) return cb('No user found'); 10 11 [ err, savedTask ] = await to(TaskModel({userId: user.id, name: 'Demo Task'})); 12 if(err) return cb('Error occurred while saving task'); 13 14 if(user.notificationsEnabled) { 15 [ err ] = await to(NotificationService.sendNotification(user.id, 'Task Created')); 16 if(err) return cb('Error while sending notification'); 17 } 18 19 if(savedTask.assignedUser.id !== user.id) { 20 [ err, notification ] = await to(NotificationService.sendNotification(savedTask.assignedUser.id, 'Task was created for you')); 21 if(err) return cb('Error while sending notification'); 22 } 23 24 cb(null, savedTask); 25} 26 27async function asyncFunctionWithThrow() { 28 const [err, user] = await to(UserModel.findById(1)); 29 if (!user) throw new Error('User not found'); 30 31}
1interface ServerResponse { 2 test: number; 3} 4 5const p = Promise.resolve({test: 123}); 6 7const [err, data] = await to<ServerResponse>(p); 8console.log(data.test);
MIT © Dima Grossman && Tomer Barnea
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 7/23 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
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
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
106 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
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