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

await-to-js

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

await-to-js - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

2

dist/types/await-to-js.d.ts

@@ -6,3 +6,3 @@ /**

*/
export declare function to<T, U = any>(promise: Promise<T>, errorExt?: object): Promise<[U | null, T | undefined]>;
export declare function to<T, U = Error>(promise: any, errorExt?: object): Promise<[U, T]>;
export default to;
{
"name": "await-to-js",
"version": "2.0.1",
"version": "2.1.0",
"description": "Async/await wrapper for easy error handling in js",

@@ -44,3 +44,2 @@ "keywords": [

"{src,test}/**/*.ts": [
"prettier --write --no-semi",
"git add"

@@ -93,3 +92,2 @@ ]

"lodash.camelcase": "^4.3.0",
"prettier": "^1.4.4",
"prompt": "^1.0.0",

@@ -106,3 +104,2 @@ "replace-in-file": "^3.0.0-beta.2",

"tslint": "^5.4.3",
"tslint-config-prettier": "^1.1.0",
"tslint-config-standard": "^6.0.0",

@@ -109,0 +106,0 @@ "typedoc": "^0.8.0",

@@ -22,5 +22,7 @@ # await-to-js

import to from 'await-to-js';
// If you use CommonJS (i.e NodeJS environment), it should be:
// const to = require('await-to-js').default;
async function asyncTask(cb) {
let err, user, savedUser, notification;
async function asyncTaskWithCb(cb) {
let err, user, savedTask, notification;

@@ -45,5 +47,11 @@ [ err, user ] = await to(UserModel.findById(1));

}
async function asyncFunctionWithThrow() {
const [err, user] = await to(UserModel.findById(1));
if (!user) throw new Error('User not found');
}
```
## Type script usage
## TypeScript usage
```javascript

@@ -50,0 +58,0 @@ interface ServerResponse {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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