{"name":"require-in-the-middle","version":"8.0.0","keywords":["require","hook","shim","shimmer","shimming","patch","monkey","monkeypatch","module","load"],"author":{"url":"https://twitter.com/wa7son","name":"Thomas Watson Steen","email":"w@tson.dk"},"license":"MIT","_id":"require-in-the-middle@8.0.0","maintainers":[{"name":"trentm","email":"trentm@gmail.com"},{"name":"watson","email":"w@tson.dk"},{"name":"nodejs-foundation","email":"build@iojs.org"}],"homepage":"https://github.com/nodejs/require-in-the-middle#readme","bugs":{"url":"https://github.com/nodejs/require-in-the-middle/issues"},"dist":{"shasum":"552c2672898c96988d558e38a8c6bc4368955686","tarball":"http://registry-npm.ywwl.com/require-in-the-middle/download/require-in-the-middle-8.0.0.tgz","fileCount":5,"integrity":"sha512-9s0pnM5tH8G4dSI3pms2GboYOs25LwOGnRMxN/Hx3TYT1K0rh6OjaWf4dI0DAQnMyaEXWoGVnSTPQasqwzTTAA==","signatures":[{"sig":"MEUCIQDwDmksJcXxLK3KlJe+9FfmAj7wGu9dmIe1wtr/+6ABbwIgGG3B9upiP1kNP8f3YIK53Q/6oaQ7Vlhgz0m/IE8KIZE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18264,"size":6361,"noattachment":false,"key":"/require-in-the-middle/-/require-in-the-middle-8.0.0.tgz"},"main":"index.js","types":"types/index.d.ts","engines":{"node":">=9.3.0 || >=8.10.0 <9.0.0"},"gitHead":"787b4228cbf91545076c54746f33800b497bbee7","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"},"_npmUser":{"name":"nodejs-foundation","email":"build@iojs.org"},"repository":{"url":"git+https://github.com/nodejs/require-in-the-middle.git","type":"git"},"_npmVersion":"10.9.3","description":"Module to hook into the Node.js require function","directories":{},"_nodeVersion":"22.19.0","dependencies":{"debug":"^4.3.5","module-details-from-path":"^1.0.3"},"_hasShrinkwrap":false,"devDependencies":{"tape":"^4.11.0","semver":"^6.3.0","patterns":"^1.0.3","standard":"^14.3.1","roundround":"^0.2.0","@babel/core":"^7.9.0","ipp-printer":"^1.0.0","@babel/register":"^7.9.0","@babel/preset-env":"^7.9.5","@babel/preset-typescript":"^7.9.0"},"_npmOperationalInternal":{"tmp":"tmp/require-in-the-middle_8.0.0_1758723621966_0.7413402094215569","host":"s3://npm-registry-packages-npm-production"},"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":1758723622167,"_cnpm_publish_time":1758723622167,"dist-tags":{"latest":"8.0.1"}}