SkillAgentSearch skills...

RequireAsync

Require any module or file async in NodeJS.

Install / Use

/learn @PaulBGD/RequireAsync
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

requireAsync

Call any function on another thread.

Installing

npm install require-async

Usage

var requireAsync = require('require-async');

var someModule = requireAsync('some-module');
var someFile = requireAsync('./file.js');

The parameters for the returned function are

  • func - the function to call inside your required module or file
  • callback - the last argument must be a callback
  • arguments - list as many arguments between this and the callback, these will be passed to the function

Example usage

var requireAsync = require('require-async');

var bcrypt = requireAsync('bcryptjs');

bcrypt('hashSync', function(err, salt) {
    if (err) {
        throw err;
    }
    console.log(salt);
}, 'bacon', 8);

Tips

  • Leave the function name blank (not null, not defined, blank) if the function is the default export.
View on GitHub
GitHub Stars21
CategoryDevelopment
Updated2y ago
Forks0

Languages

TypeScript

Security Score

60/100

Audited on May 25, 2023

No findings