Socket
Socket
Sign inDemoInstall

es6-promisify

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es6-promisify

Converts callback-based functions to ES6 Promises


Version published
Weekly downloads
3.7M
increased by0.98%
Maintainers
1
Weekly downloads
 
Created

What is es6-promisify?

The es6-promisify package is a utility that converts callback-based functions to return Promises, making it easier to work with asynchronous code in a more modern and readable way.

What are es6-promisify's main functionalities?

Promisify a single callback-based function

This feature allows you to convert a single callback-based function, such as `fs.readFile`, into a function that returns a Promise. This makes it easier to handle asynchronous operations using modern async/await syntax or Promise chaining.

const promisify = require('es6-promisify');
const fs = require('fs');
const readFileAsync = promisify(fs.readFile);

readFileAsync('example.txt', 'utf8')
  .then(data => console.log(data))
  .catch(err => console.error(err));

Promisify an entire object of callback-based functions

This feature allows you to promisify all functions within an object, such as the `fs` module, so that all of its methods return Promises. This is useful for working with modules that have multiple callback-based methods.

const promisify = require('es6-promisify');
const fs = require('fs');
const fsAsync = promisify(fs);

fsAsync.readFile('example.txt', 'utf8')
  .then(data => console.log(data))
  .catch(err => console.error(err));

Other packages similar to es6-promisify

Keywords

FAQs

Package last updated on 26 May 2021

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