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 1.0.0 to 1.0.1

2

package.json
{
"name": "await-to-js",
"version": "1.0.0",
"version": "1.0.1",
"description": "Async/await wrapper for easy error handling in js",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -7,2 +7,3 @@ # await-to-js

> Async await wrapper for easy error handling
## Pre-requisites

@@ -24,15 +25,17 @@ You need ES7 transpiler in order to use async/await functionality.

async function asyncTask(cb) {
const [ err, user ] = await to(UserModel.findById(1));
let err, user, savedUser, notification;
[ err, user ] = await to(UserModel.findById(1));
if(!user) return cb('No user found');
const [ err, savedTask ] = await to(TaskModel({userId: user.id, name: 'Demo Task'}));
[ err, savedTask ] = await to(TaskModel({userId: user.id, name: 'Demo Task'}));
if(err) return cb('Error occurred while saving task');
if(user.notificationsEnabled) {
const [ err ] = await to(NotificationService.sendNotification(user.id, 'Task Created'));
if(err) return cb('Error while sending notification');
[ err ] = await to(NotificationService.sendNotification(user.id, 'Task Created'));
if(err) return cb('Error while sending notification');
}
if(savedTask.assignedUser.id !== user.id) {
const [ err, notification ] = await to(NotificationService.sendNotification(savedTask.assignedUser.id, 'Task was created for you'));
[ err, notification ] = await to(NotificationService.sendNotification(savedTask.assignedUser.id, 'Task was created for you'));
if(err) return cb('Error while sending notification');

@@ -39,0 +42,0 @@ }

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