{"name":"require-in-the-middle","version":"7.5.2","description":"Module to hook into the Node.js require function","main":"index.js","types":"types/index.d.ts","dependencies":{"debug":"^4.3.5","module-details-from-path":"^1.0.3","resolve":"^1.22.8"},"devDependencies":{"@babel/core":"^7.9.0","@babel/preset-env":"^7.9.5","@babel/preset-typescript":"^7.9.0","@babel/register":"^7.9.0","ipp-printer":"^1.0.0","patterns":"^1.0.3","roundround":"^0.2.0","semver":"^6.3.0","standard":"^14.3.1","tape":"^4.11.0"},"scripts":{"test":"npm run test:lint && npm run test:tape && npm run test:babel","test:lint":"standard","test:tape":"tape test/*.js","test:babel":"node test/babel/babel-register.js"},"repository":{"type":"git","url":"git+https://github.com/nodejs/require-in-the-middle.git"},"keywords":["require","hook","shim","shimmer","shimming","patch","monkey","monkeypatch","module","load"],"author":{"name":"Thomas Watson Steen","email":"w@tson.dk","url":"https://twitter.com/wa7son"},"license":"MIT","bugs":{"url":"https://github.com/nodejs/require-in-the-middle/issues"},"homepage":"https://github.com/nodejs/require-in-the-middle#readme","engines":{"node":">=8.6.0"},"_id":"require-in-the-middle@7.5.2","gitHead":"f7b785370fb1b9a239e4aac54da76e9525a71964","_nodeVersion":"22.13.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-gAZ+kLqBdHarXB64XpAe2VCjB7rIRv+mU8tfRWziHRJ5umKsIHN2tLLv6EtMw7WCdP19S0ERVMldNvxYCHnhSQ==","shasum":"dc25b148affad42e570cf0e41ba30dc00f1703ec","tarball":"http://registry-npm.ywwl.com/require-in-the-middle/download/require-in-the-middle-7.5.2.tgz","fileCount":5,"unpackedSize":20017,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD5sw0wtg9+o10yUxXriyJi0KTF8XQAd2LPMDgnu/+vdQIhAPaI9Q45hISMThdNDvUBMmtSOjouRZLnLoP255YPdmR9"}],"size":6841,"noattachment":false,"key":"/require-in-the-middle/-/require-in-the-middle-7.5.2.tgz"},"_npmUser":{"name":"nodejs-foundation","email":"build@iojs.org"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/require-in-the-middle_7.5.2_1740163091500_0.34711591787687834"},"_hasShrinkwrap":false,"readme":"# require-in-the-middle\n\nHook into the Node.js `require` function. This allows you to modify\nmodules on-the-fly as they are being required.\n\n[![npm](https://img.shields.io/npm/v/require-in-the-middle.svg)](https://www.npmjs.com/package/require-in-the-middle)\n[![Test status](https://github.com/nodejs/require-in-the-middle/workflows/Test/badge.svg)](https://github.com/nodejs/require-in-the-middle/actions)\n\nAlso supports hooking into calls to `process.getBuiltinModule()`, which was introduced in Node.js v22.3.0.\n\n## Installation\n\n```\nnpm install require-in-the-middle --save\n```\n\n## Usage\n\n```js\nconst path = require('path')\nconst { Hook } = require('require-in-the-middle')\n\n// Hook into the express and mongodb module\nnew Hook(['express', 'mongodb'], function (exports, name, basedir) {\n  const version = require(path.join(basedir, 'package.json')).version\n\n  console.log('loading %s@%s', name, version)\n\n  // expose the module version as a property on its exports object\n  exports._version = version\n\n  // whatever you return will be returned by `require`\n  return exports\n})\n```\n\n## API\n\nThe require-in-the-middle module exposes a single function:\n\n### `hook = new Hook([modules][, options], onrequire)`\n\nWhen called a `hook` object is returned.\n\nArguments:\n\n- `modules` &lt;string[]> An optional array of module names to limit which modules\n  trigger a call of the `onrequire` callback. If specified, this must be the\n  first argument. Both regular modules (e.g. `react-dom`) and\n  sub-modules (e.g. `react-dom/server`) can be specified in the array.\n- `options` &lt;Object> An optional object containing fields that change when the\n  `onrequire` callback is called. If specified, this must be the second\n  argument.\n  - `options.internals` &lt;boolean> Specifies whether `onrequire` should be called\n    when module-internal files are loaded; defaults to `false`.\n- `onrequire` &lt;Function> The function to call when a module is required.\n\nThe `onrequire` callback will be called the first time a module is\nrequired. The function is called with three arguments:\n\n- `exports` &lt;Object> The value of the `module.exports` property that would\n  normally be exposed by the required module.\n- `name` &lt;string> The name of the module being required. If `options.internals`\n  was set to `true`, the path of module-internal files that are loaded\n  (relative to `basedir`) will be appended to the module name, separated by\n  `path.sep`.\n- `basedir` &lt;string> The directory where the module is located, or `undefined`\n  for core modules.\n\nReturn the value you want the module to expose (normally the `exports`\nargument).\n\n### `hook.unhook()`\n\nRemoves the `onrequire` callback so that it will not be triggerd by\nsubsequent calls to `require()` or `process.getBuiltinModule()`.\n\n## License\n\n[MIT](https://github.com/nodejs/require-in-the-middle/blob/master/LICENSE)\n","publish_time":1740163091698,"maintainers":[{"name":"trentm","email":"trentm@gmail.com"},{"name":"watson","email":"w@tson.dk"},{"name":"nodejs-foundation","email":"build@iojs.org"}],"_cnpm_publish_time":1740163091698,"dist-tags":{"latest":"8.0.1"}}