Socket
Socket
Sign inDemoInstall

just-defer

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    just-defer

Create a simple defer


Version published
Weekly downloads
102
decreased by-22.73%
Maintainers
1
Install size
3.73 kB
Created
Weekly downloads
 

Readme

Source

Just Defer

Do you have a lot of callbacks but you like Promises more? Have you written the same one function into many projects? Would you like to use Async more?

Just defer your callbacks!

Installation

npm i just-defer

Usage

Resolve and Reject

const justDefer = require('just-defer');
const { promise, resolve, reject } = justDefer();

fs.readFile('/etc/passwd', (err, res) => {
    if(err) return reject(err);
    resolve(res);
});
const passwd = await promise;

console.log('passwd contents', passwd);

Callback

const justDefer = require('just-defer');
const { promise, callback } = justDefer();

fs.readFile('/etc/passwd', callback);
const passwd = await promise;

console.log('passwd contents', passwd);

License

Copyright (c) 2021, Michael Szmadzinski. (MIT License)

FAQs

Last updated on 24 Nov 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc