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

1.0.2 • 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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.20latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.20
1.0.10

Package Sidebar

Install

npm i @blowback/contextify

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

14.6 kB

Total Files

8

Last publish

Collaborators

  • antonio.presto