blowback
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Blowback

Contextify

Creates a contextualized copy of node require

// ./tasks/module1.js
const getContext = require('my-context-module');

module.exports = () => {
  return getContext().myContextValueABC;
};

// index.js
import { Contextify } from 'blowback';
const { prepareRequire } = new Contextify({
  contextModuleName: 'my-context-module',
});

const require = prepareRequire({
  currentDirname: __dirname + '/tasks',
  payload: { myContextValueABC: 'abc321' },
});

const contextified = require('./module1');
console.log(contextified()); // -> abc321

/blowback/

    Package Sidebar

    Install

    npm i blowback

    Weekly Downloads

    1

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    18.2 kB

    Total Files

    6

    Last publish

    Collaborators

    • antonio.presto