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

node-callback-style-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-callback-style-wrapper

Promise wrapper for callback style code

  • 1.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

node-callback-style-wrapper

npm version

Node callback style (also know as error first callback) was great, it arrived as the perfect match with the idea of creating non-blocking software, the win of callbacks over event handlers was instrumental in the growth of modern JS development.

Nowadays the solution is too coupled with the imperative programming paradigm, in 2017 we want to write more declarative code, we don't want to add if statements to check if our callback threw an error.

Promises came to rescue us from the callback nightmare!

The best way to write this declarative code is to use promises, promises belong to the 3rd generation of async programming and they represent the eventual result of an asynchronous operation.

This small module is just a Promisse wrapper for your callbacks.

Install

yarn add -D node-callback-style-wrapper

Example of Usage

const wrapper = require('node-callback-style-wrapper');
const fs = require('fs');

wrapper(fs.readdir, './path/to/my/dir')
   .then((x) => { doStuff(x) })
   .catch((err) => { console.error("Unexpected error", err) })
   

Keywords

FAQs

Package last updated on 30 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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