Socket
Book a DemoInstallSign in
Socket

decb

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decb

promisified modules

latest
Source
npmnpm
Version
1.3.2
Version published
Maintainers
1
Created
Source

decb

decb is a module that translates modules to a promisified version of them. Note that it is not possible to differentiate between asynchronous and synchronous functions, so (if needed) it has do be done manually.

Code Example

Use fs.readFile with Promises:

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

    fs.readFile('example.js', 'utf8').then(file => {
        console.log(file);
    });

    console.log(fs.readFileSync('example.js', 'utf8'));
    //Returns a promise and does not work

Use fs.readFile with Promises, but don't translate fs.readFileSync

    const decb = require('decb');
    const fs = decb(require('fs'), {
      ignore: ['readFileSync']
    });

    fs.readFile('example.js', 'utf8').then(file => {
        console.log(file);
    });

    console.log(fs.readFileSync('example.js', 'utf8'));
    //Works as expected

Use fs.readFile with Promises, but don't change the rest of the module

    const decb = require('decb');
    const fs = decb(require('fs'), {
      use: ['readFile']
    });

    fs.readFile('example.js', 'utf8').then(file => {
        console.log(file);
    });

    console.log(fs.readFileSync('example.js', 'utf8'));
    console.log(fs.readdirSync('lib'));
    //Works as expected

Installation

$ npm install decb

API

###decb(module[,config])

  • module: an npm module to translate
  • config: a config object with either an ignore or use property

Returns a promisified version of the module

License

MIT

Keywords

promise

FAQs

Package last updated on 06 Aug 2016

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.