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

thunkify

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

thunkify

Turn callbacks, arrays, generators, generator functions, and promises into a thunk

  • 2.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is thunkify?

The 'thunkify' npm package is used to convert functions that take a callback into functions that return thunks. Thunks are functions that encapsulate a computation or action to be performed later, which can be particularly useful in asynchronous programming.

What are thunkify's main functionalities?

Convert callback-based functions to thunks

This feature allows you to convert a function that uses a callback (like 'fs.readFile') into a function that returns a thunk. The thunk can then be called with a callback to execute the original function.

const thunkify = require('thunkify');
const fs = require('fs');

const readFileThunk = thunkify(fs.readFile);

const thunk = readFileThunk('example.txt', 'utf8');

thunk((err, data) => {
  if (err) throw err;
  console.log(data);
});

Other packages similar to thunkify

Keywords

FAQs

Package last updated on 02 Jun 2014

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