{"_id":"requizzle","_rev":"2995737","name":"requizzle","description":"Swizzle a little something into your require() calls.","dist-tags":{"latest":"0.2.4"},"maintainers":[{"name":"hegemonic","email":"jeffrey.l.williams@gmail.com"}],"time":{"modified":"2023-08-28T09:21:19.000Z","created":"2014-06-10T00:09:23.187Z","0.2.4":"2022-11-26T00:44:43.849Z","0.2.3":"2019-07-14T17:27:40.396Z","0.2.2":"2019-05-04T22:39:46.096Z","0.2.1":"2014-12-05T22:26:02.452Z","0.2.0":"2014-06-15T18:35:08.227Z","0.1.1":"2014-06-11T16:11:30.380Z","0.1.0":"2014-06-10T00:09:23.187Z"},"users":{"rbecheras":true},"author":{"name":"Jeff Williams","email":"jeffrey.l.williams@gmail.com"},"repository":{"type":"git","url":"git://github.com/hegemonic/requizzle.git"},"versions":{"0.2.4":{"name":"requizzle","version":"0.2.4","description":"Swizzle a little something into your require() calls.","main":"index.js","scripts":{"test":"gulp test"},"repository":{"type":"git","url":"git://github.com/hegemonic/requizzle.git"},"keywords":["module","modules","require","inject","dependency","swizzle"],"author":{"name":"Jeff Williams","email":"jeffrey.l.williams@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/hegemonic/requizzle/issues"},"homepage":"https://github.com/hegemonic/requizzle","dependencies":{"lodash":"^4.17.21"},"devDependencies":{"@jsdoc/eslint-config":"^1.1.9","@jsdoc/prettier-config":"^0.1.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.2.1","expectations":"^1.0.0","gulp":"^4.0.2","gulp-eslint-new":"^1.7.0","gulp-mocha":"^8.0.0"},"gitHead":"c9f151213cbb5770cd6f829f6132bb83fa18b7e2","_id":"requizzle@0.2.4","_nodeVersion":"18.12.1","_npmVersion":"8.19.2","dist":{"shasum":"319eb658b28c370f0c20f968fa8ceab98c13d27c","size":6745,"noattachment":false,"key":"/requizzle/-/requizzle-0.2.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/requizzle/download/requizzle-0.2.4.tgz"},"_npmUser":{"name":"hegemonic","email":"jeffrey.l.williams@gmail.com"},"directories":{},"maintainers":[{"name":"hegemonic","email":"jeffrey.l.williams@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/requizzle_0.2.4_1669423483623_0.043294149342879784"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-11-26T00:44:47.998Z","publish_time":1669423483849,"_cnpm_publish_time":1669423483849},"0.2.3":{"name":"requizzle","version":"0.2.3","description":"Swizzle a little something into your require() calls.","main":"index.js","scripts":{"test":"gulp test"},"repository":{"type":"git","url":"git://github.com/hegemonic/requizzle.git"},"keywords":["module","modules","require","inject","dependency","swizzle"],"author":{"name":"Jeff Williams","email":"jeffrey.l.williams@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/hegemonic/requizzle/issues"},"homepage":"https://github.com/hegemonic/requizzle","dependencies":{"lodash":"^4.17.14"},"devDependencies":{"expectations":"^1.0.0","gulp":"^4.0.2","gulp-eslint":"^6.0.0","gulp-mocha":"^6.0.0"},"gitHead":"f6157db86369eaff60dd6d439a7b589ebf9418ea","_id":"requizzle@0.2.3","_nodeVersion":"8.16.0","_npmVersion":"6.10.0","_npmUser":{"name":"hegemonic","email":"jeffrey.l.williams@gmail.com"},"dist":{"shasum":"4675c90aacafb2c036bd39ba2daa4a1cb777fded","size":6804,"noattachment":false,"key":"/requizzle/-/requizzle-0.2.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/requizzle/download/requizzle-0.2.3.tgz"},"maintainers":[{"name":"hegemonic","email":"jeffrey.l.williams@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/requizzle_0.2.3_1563125260233_0.5023768287287425"},"_hasShrinkwrap":false,"publish_time":1563125260396,"_cnpm_publish_time":1563125260396},"0.2.2":{"name":"requizzle","version":"0.2.2","description":"Swizzle a little something into your require() calls.","main":"index.js","scripts":{"test":"gulp test"},"repository":{"type":"git","url":"git://github.com/hegemonic/requizzle.git"},"keywords":["module","modules","require","inject","dependency","swizzle"],"author":{"name":"Jeff Williams","email":"jeffrey.l.williams@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/hegemonic/requizzle/issues"},"homepage":"https://github.com/hegemonic/requizzle","devDependencies":{"expectations":"^1.0.0","gulp":"^4.0.1","gulp-eslint":"^5.0.0","gulp-mocha":"^6.0.0"},"dependencies":{"lodash":"^4.17.11"},"gitHead":"3193e1bed6fdfe69fbde99496da6ed383a160680","_id":"requizzle@0.2.2","_npmVersion":"6.4.1","_nodeVersion":"8.16.0","_npmUser":{"name":"hegemonic","email":"jeffrey.l.williams@gmail.com"},"dist":{"shasum":"df991c0cffbbbdde721504c1455f68f53f7c7bd1","size":6768,"noattachment":false,"key":"/requizzle/-/requizzle-0.2.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/requizzle/download/requizzle-0.2.2.tgz"},"maintainers":[{"name":"hegemonic","email":"jeffrey.l.williams@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/requizzle_0.2.2_1557009585960_0.8876718899167826"},"_hasShrinkwrap":false,"publish_time":1557009586096,"_cnpm_publish_time":1557009586096},"0.2.1":{"name":"requizzle","version":"0.2.1","description":"Swizzle a little something into your require() calls.","main":"index.js","scripts":{"test":"gulp test"},"repository":{"type":"git","url":"git://github.com/hegemonic/requizzle.git"},"keywords":["module","modules","require","inject","dependency","swizzle"],"author":{"name":"Jeff Williams","email":"jeffrey.l.williams@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/hegemonic/requizzle/issues"},"homepage":"https://github.com/hegemonic/requizzle","devDependencies":{"expectations":"~0.2.5","gulp":"~3.8.0","gulp-eslint":"~0.1.6","gulp-istanbul":"~0.2.0","gulp-istanbul-enforcer":"~1.0.2","gulp-mocha":"~0.4.1"},"dependencies":{"underscore":"~1.6.0"},"gitHead":"be5b922edf3e08e487bf374d6add13f8da581abf","_id":"requizzle@0.2.1","_shasum":"6943c3530c4d9a7e46f1cddd51c158fc670cdbde","_from":".","_npmVersion":"2.1.9","_nodeVersion":"0.10.33","_npmUser":{"name":"hegemonic","email":"jeffrey.l.williams@gmail.com"},"maintainers":[{"name":"hegemonic","email":"jeffrey.l.williams@gmail.com"}],"dist":{"shasum":"6943c3530c4d9a7e46f1cddd51c158fc670cdbde","size":6659,"noattachment":false,"key":"/requizzle/-/requizzle-0.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/requizzle/download/requizzle-0.2.1.tgz"},"directories":{},"publish_time":1417818362452,"_cnpm_publish_time":1417818362452,"_hasShrinkwrap":false},"0.2.0":{"name":"requizzle","version":"0.2.0","description":"Swizzle a little something into your require() calls.","main":"index.js","scripts":{"test":"gulp test"},"repository":{"type":"git","url":"git://github.com/hegemonic/requizzle.git"},"keywords":["module","modules","require","inject","dependency","swizzle"],"author":{"name":"Jeff Williams","email":"jeffrey.l.williams@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/hegemonic/requizzle/issues"},"homepage":"https://github.com/hegemonic/requizzle","devDependencies":{"expectations":"~0.2.5","gulp":"~3.8.0","gulp-eslint":"~0.1.6","gulp-istanbul":"~0.2.0","gulp-istanbul-enforcer":"~1.0.2","gulp-mocha":"~0.4.1"},"dependencies":{"underscore":"~1.6.0"},"gitHead":"696c5ca079822fba78522f56b223404600481434","_id":"requizzle@0.2.0","_shasum":"ea93c7b441ce168052391860b55a7b508c391cbd","_from":".","_npmVersion":"1.4.13","_npmUser":{"name":"hegemonic","email":"jeffrey.l.williams@gmail.com"},"maintainers":[{"name":"hegemonic","email":"jeffrey.l.williams@gmail.com"}],"dist":{"shasum":"ea93c7b441ce168052391860b55a7b508c391cbd","size":6639,"noattachment":false,"key":"/requizzle/-/requizzle-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/requizzle/download/requizzle-0.2.0.tgz"},"directories":{},"publish_time":1402857308227,"_cnpm_publish_time":1402857308227,"_hasShrinkwrap":false},"0.1.1":{"name":"requizzle","version":"0.1.1","description":"Swizzle a little something into your require() calls.","main":"index.js","scripts":{"test":"gulp test"},"repository":{"type":"git","url":"git://github.com/hegemonic/requizzle.git"},"keywords":["module","modules","require","inject","dependency","swizzle"],"author":{"name":"Jeff Williams","email":"jeffrey.l.williams@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/hegemonic/requizzle/issues"},"homepage":"https://github.com/hegemonic/requizzle","devDependencies":{"expectations":"~0.2.5","gulp":"~3.8.0","gulp-eslint":"~0.1.6","gulp-istanbul":"~0.2.0","gulp-istanbul-enforcer":"~1.0.2","gulp-mocha":"~0.4.1"},"dependencies":{"underscore":"~1.6.0"},"gitHead":"51aaeff58bf966d9a8df41bb9cc88587edc608bc","_id":"requizzle@0.1.1","_shasum":"bad811e66c59251fe97e084295c33bcdbcf8e0ba","_from":".","_npmVersion":"1.4.15","_npmUser":{"name":"hegemonic","email":"jeffrey.l.williams@gmail.com"},"maintainers":[{"name":"hegemonic","email":"jeffrey.l.williams@gmail.com"}],"dist":{"shasum":"bad811e66c59251fe97e084295c33bcdbcf8e0ba","size":6677,"noattachment":false,"key":"/requizzle/-/requizzle-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/requizzle/download/requizzle-0.1.1.tgz"},"directories":{},"publish_time":1402503090380,"_cnpm_publish_time":1402503090380,"_hasShrinkwrap":false},"0.1.0":{"name":"requizzle","version":"0.1.0","description":"Swizzle a little something into your require() calls.","main":"index.js","scripts":{"test":"gulp test"},"repository":{"type":"git","url":"git://github.com/hegemonic/requizzle.git"},"keywords":["module","modules","require","inject","dependency","swizzle"],"author":{"name":"Jeff Williams","email":"jeffrey.l.williams@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/hegemonic/requizzle/issues"},"homepage":"https://github.com/hegemonic/requizzle","devDependencies":{"expectations":"~0.2.5","gulp":"~3.6.2","gulp-eslint":"~0.1.6","gulp-istanbul":"~0.2.0","gulp-istanbul-enforcer":"~1.0.2","gulp-mocha":"~0.4.1"},"dependencies":{"underscore":"~1.6.0"},"_id":"requizzle@0.1.0","_shasum":"f07a630ba62e188f64ccb7d408bff31787e83793","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"hegemonic","email":"jeffrey.l.williams@gmail.com"},"maintainers":[{"name":"hegemonic","email":"jeffrey.l.williams@gmail.com"}],"dist":{"shasum":"f07a630ba62e188f64ccb7d408bff31787e83793","size":6371,"noattachment":false,"key":"/requizzle/-/requizzle-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/requizzle/download/requizzle-0.1.0.tgz"},"directories":{},"publish_time":1402358963187,"_cnpm_publish_time":1402358963187,"_hasShrinkwrap":false}},"readme":"# Requizzle\n\n![Build status](https://github.com/hegemonic/requizzle/actions/workflows/build.yaml/badge.svg?branch=main)\n\nSwizzle a little something into your Node.js modules.\n\n## What's Requizzle?\n\nRequizzle provides a drop-in replacement for Node.js's `require()` function.\nThis replacement enables you to change a module's source code when Node.js loads\nthe module.\n\nYou can use Requizzle in your test cases, or in production code if you like to\nlive dangerously.\n\n## How can I change a module with Requizzle?\n\nThere are several different ways:\n\n### Look for modules in new places\n\nWith Requizzle, you can add directories to the module lookup path, which forces\nNode.js to search those directories for modules. This can be useful if:\n\n+ You're tired of writing code like `require('../../../../../lib/foo')`.\n+ You want to expose your app's modules to external plugins.\n\n### Add code before or after the module's source code\n\nTamper with modules to your heart's delight by adding arbitrary code before or\nafter the module's own source code.\n\n### Mess with child modules\n\nWhen you use Requizzle to require a module, you can force each child module's\n`require` method to inherit your changes to the parent module. (By default, only\nthe parent module is changed.)\n\n## Will Requizzle break my dependencies?\n\nProbably not. It's true that Requizzle gives you plenty of new and exciting ways\nto tamper with, and possibly break, your module dependencies. But Requizzle also\ntries not to break anything on its own. In particular:\n\n+ **Requizzle preserves strict-mode declarations**.  If a module starts with a\nstrict-mode declaration, Requizzle keeps it in place. Your changes will appear\nafter the strict-mode declaration.\n+ **Requizzle leaves native modules alone**. If you use Requizzle to load one of\nNode.js's built-in modules, such as `fs` or `path`, Requizzle won't mess with\nit.\n\n## Usage\n\nThe Requizzle module exports a single function, which returns a drop-in\nreplacement for `require()`.\n\nWhen you call the function, you must pass in an `options` object, which can\ninclude any of these properties:\n\n+ `extras`: A pair of functions that return text to insert before or after the\nmodule's source code. Each function accepts two parameters: `targetPath`, the\npath to the required module, and `parentModule`, the `Module` object for the\nmodule's parent. Each function must return a string.\n    + `extras.before`: A function that returns text to insert before the\n    module's source code.\n    + `extras.after`: A function that returns text to insert after the module's\n    source code.\n+ `infect`: Determines whether child modules are infected with the same changes\nas the parent module. Set to `true` to force child modules to inherit your\nchanges. Defaults to `false`.\n+ `requirePaths`: Additional paths to search for required modules. For example,\nif `requirePaths` is set to `['/usr/lib/junk/modules']`, and you save a\nJavaScript module at `/usr/lib/junk/modules/mymodule.js`, you can require the\nmodule as `mymodule`.\n\n    You can provide an array of paths, which will be searched before the default\n    module paths, or an object with the following properties:\n\n    + `requirePaths.before`: An array of paths to search before the default\n    module paths.\n    + `requirePaths.after`: An array of paths to search after the default module\n    paths. Use this property if you want the module to use its own local\n    dependencies when possible, then fall back to the additional paths if\n    necessary.\n\n    By default, the require path is not changed.\n\n## Examples\n\n```js\nconst requizzle = require('requizzle');\n\n// Say hello and goodbye to each module.\nconst logRequire = requizzle({\n  extras: {\n    before: function(targetPath, parentModule) {\n      return 'console.log(\"Hello %s!\", ' + targetPath + ');\\n';\n    },\n    after: function(targetPath, parentModule) {\n      return 'console.log(\"Goodbye %s!\", ' + targetPath + ');\\n';\n    }\n  }\n});\n// Prints \"Hello /path/to/mymodule.js!\" and \"Goodbye /path/to/mymodule.js!\"\nconst myModule = logRequire('mymodule');\n\n// Look for modules in the current module's `lib` directory, and force child\n// modules to do the same.\nconst path = require('path');\nconst extraPathRequire = requizzle({\n  infect: true,\n  requirePaths: [path.join(__dirname, 'lib')]\n});\n// If `foo` needs to require a module in `./lib`, it can use `require('bar')`\n// instead of `require('./lib/bar')`.\nconst foo = extraPathRequire('./foo');\n```\n\n## Troubleshooting\n\nHere are some problems you might run into when you use Requizzle, along with\nsolutions to each problem. If you run into any problems that aren't addressed\nhere, please file a new issue!\n\n### Requizzle slowed down my code! A lot!\n\nRequizzle adds minimal overhead to the module-loading process. However, your\ncode will run _much_ slower than usual if you do both of the following:\n\n+ Use Requizzle's `infect` option.\n+ Require modules that have a lot of `require()` calls within the scope of\nindividual functions.\n\nIf Requizzle seems to slow down your app, look for module calls that are within\nfunction scope, then move them to each module's top-level scope.\n\n### Requizzle made my module do something weird!\n\nDo you have any\n[circular dependencies](https://nodejs.org/api/modules.html#modules_cycles) in\nthe modules that aren't working? Circular dependencies can cause unusual\nbehavior with Requizzle, just as they can without Requizzle. Try breaking the\ncircular dependency.\n\n### Requizzle violates the [Law of Demeter](https://wikipedia.org/wiki/Law_of_Demeter)! It's an unnatural abomination!\n\nFair enough.\n\n## Changelog\n\n+ 0.2.4 (November 2022): Fixed a compatibility issue with\n[core modules](https://nodejs.org/docs/latest-v18.x/api/modules.html#core-modules)\nthat are loaded with the `node:` prefix, as in `require('node:fs')`.\n+ 0.2.3 (July 2019): Updated dependencies.\n+ 0.2.2 (May 2019): Fixed a compability issue with Node.js 12.\n+ 0.2.1 (December 2014): The `requirePaths` option no longer inserts an extra\nline break into the source file.\n+ 0.2.0 (June 2014): The `requirePaths` option can now contain `before` and\n`after` properties. Paths in the `before` property will be searched first; paths\nin the `after` property will be searched last.\n+ 0.1.1 (June 2014): If the `requirePaths` option is used, the module loader now\nsearches the extra paths first rather than last.\n+ 0.1.0 (June 2014): Initial release.\n\n## Acknowledgements\n\nRequizzle is very loosely adapted from Johannes Ewald's\n[rewire](https://github.com/jhnns/rewire) module, which is designed to modify a\nmodule's behavior for unit testing. If Requizzle doesn't meet your needs, please\ntake a look at rewire!\n\n## License\n\n[MIT license](https://github.com/hegemonic/requizzle/blob/main/LICENSE).\n","_attachments":{},"homepage":"https://github.com/hegemonic/requizzle","bugs":{"url":"https://github.com/hegemonic/requizzle/issues"},"license":"MIT"}