{"_id":"require-new","_rev":"13-b72f08868c7f1a988ca6f2eec03cb621","name":"require-new","description":"Requires a new module object.","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"require-new","description":"Requires a new module object.","keywords":["require","module","cache","reload","test"],"version":"1.0.0","main":"src/require-new.js","author":{"name":"Gajus Kuizinas","email":"gk@anuary.com"},"repository":{"type":"git","url":"https://github.com/gajus/require-new"},"license":"BSD-3-Clause","scrips":{"test":"gulp test"},"devDependencies":{"chai":"^1.9.2","gulp":"^3.8.9","gulp-jshint":"^1.8.6","gulp-mocha":"^1.1.1"},"gitHead":"13cfe2e3dc923d623f581ea46cb64a91b1ada519","bugs":{"url":"https://github.com/gajus/require-new/issues"},"homepage":"https://github.com/gajus/require-new","_id":"require-new@1.0.0","scripts":{},"_shasum":"874ec9e1a55719280cb5fa1dd62498ecb6b56899","_from":".","_npmVersion":"2.1.6","_nodeVersion":"0.10.33","_npmUser":{"name":"gajus","email":"gk@anuary.com"},"maintainers":[{"name":"gajus","email":"gk@anuary.com"}],"dist":{"shasum":"874ec9e1a55719280cb5fa1dd62498ecb6b56899","tarball":"https://registry.npmjs.org/require-new/-/require-new-1.0.0.tgz","integrity":"sha512-c/9ckEX0RU/IxzYL06d6odinm0HMf2aq6Y9f+1FErHBeQp4eDNnbhXUjHUFCCSjvS8fMup95zlboVdEsQX7w2A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDdjFWY3K1fLriX/IydFGcDEQVjkjfsG7/CudMM5GVw0gIgNDX9Psh/VesobaAILTEGzhcDBR4yWvHTPPtyZoJuEno="}]}},"1.0.1":{"name":"require-new","description":"Requires a new module object.","keywords":["require","module","cache","reload","test"],"version":"1.0.1","main":"src/require-new.js","author":{"name":"Gajus Kuizinas","email":"gk@anuary.com"},"repository":{"type":"git","url":"https://github.com/gajus/require-new"},"license":"BSD-3-Clause","scrips":{"test":"gulp test"},"devDependencies":{"chai":"^1.9.2","gulp":"^3.8.9","gulp-jshint":"^1.8.6","gulp-mocha":"^1.1.1"},"gitHead":"c3447a51a85dfa81dc90772a00f318582464eff6","bugs":{"url":"https://github.com/gajus/require-new/issues"},"homepage":"https://github.com/gajus/require-new","_id":"require-new@1.0.1","scripts":{},"_shasum":"88f9db65e083f66d37bc7ceecdb4a194b8c49116","_from":".","_npmVersion":"2.1.6","_nodeVersion":"0.10.33","_npmUser":{"name":"gajus","email":"gk@anuary.com"},"maintainers":[{"name":"gajus","email":"gk@anuary.com"}],"dist":{"shasum":"88f9db65e083f66d37bc7ceecdb4a194b8c49116","tarball":"https://registry.npmjs.org/require-new/-/require-new-1.0.1.tgz","integrity":"sha512-WiRx8Mwenz0zWL+W7xKT68OHnUhj7YMiMHOjTohrbR7yPA5zJlbxXQ+l3SfsPNgR+wZqRhQRgpftCB2W8dQzDw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCueTGoxnigmX4k+P51QML9M2QHi4Y1K+A3wLSNJZmdoQIhAN4pSYPZCxR6O2kM3VtZqZmoOWz7WyfKC4bRZojia1kp"}]}},"1.0.2":{"name":"require-new","description":"Requires a new module object.","keywords":["require","module","cache","reload","test"],"version":"1.0.2","main":"src/require-new.js","author":{"name":"Gajus Kuizinas","email":"gk@anuary.com"},"repository":{"type":"git","url":"https://github.com/gajus/require-new"},"license":"BSD-3-Clause","scrips":{"test":"gulp test"},"devDependencies":{"chai":"^1.9.2","gulp":"^3.8.9","gulp-jshint":"^1.8.6","gulp-mocha":"^1.1.1"},"dependencies":{"stack-trace":"0.0.9"},"gitHead":"2f6223e9f79c2dc0b09588d8d7fda18811f33e80","bugs":{"url":"https://github.com/gajus/require-new/issues"},"homepage":"https://github.com/gajus/require-new","_id":"require-new@1.0.2","scripts":{},"_shasum":"74bf64b9028cdf1067d4eb458a25026c78710a5d","_from":".","_npmVersion":"2.1.6","_nodeVersion":"0.10.33","_npmUser":{"name":"gajus","email":"gk@anuary.com"},"maintainers":[{"name":"gajus","email":"gk@anuary.com"}],"dist":{"shasum":"74bf64b9028cdf1067d4eb458a25026c78710a5d","tarball":"https://registry.npmjs.org/require-new/-/require-new-1.0.2.tgz","integrity":"sha512-hMMMvCj5CGisGCawwuWCGi019R48gF0iKU41L35zbT/w8K06/qXLwiYMko/qTELmHXBgE4Yha1A1T4qkz9HvXQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCKTI0v4+Oh8usRLrnCr83Mh3aBRrFQeb7iR3qTJPt/LAIhAIInC5sNF0hm2DlelK0zmn8xpkTyYgpxrOUzKRCudFAi"}]}},"1.1.0":{"name":"require-new","description":"Requires a new module object.","keywords":["require","module","cache","reload","test"],"version":"1.1.0","main":"src/index.js","author":{"name":"Gajus Kuizinas","email":"gk@anuary.com"},"repository":{"type":"git","url":"git+https://github.com/gajus/require-new.git"},"license":"BSD-3-Clause","scrips":{"test":"gulp test"},"devDependencies":{"chai":"^3.2.0","gitdown":"^1.3.2","gulp":"^3.9.0","gulp-eslint":"^1.0.0","gulp-mocha":"^2.1.3"},"dependencies":{"stack-trace":"^0.0.9"},"gitHead":"fac1d5df405d26500b0af055d484a8615a4ec120","bugs":{"url":"https://github.com/gajus/require-new/issues"},"homepage":"https://github.com/gajus/require-new#readme","_id":"require-new@1.1.0","scripts":{},"_shasum":"6a155d5fca9c90dc74dd9c862f7d04f8213f3802","_from":".","_npmVersion":"2.13.2","_nodeVersion":"2.5.0","_npmUser":{"name":"gajus","email":"gk@anuary.com"},"maintainers":[{"name":"gajus","email":"gk@anuary.com"}],"dist":{"shasum":"6a155d5fca9c90dc74dd9c862f7d04f8213f3802","tarball":"https://registry.npmjs.org/require-new/-/require-new-1.1.0.tgz","integrity":"sha512-70hNfljffuINB0gTtNfThvGlzRh0misW0XWPHVfwmtefFRdZAXPwYnnPaELEbTdhaWILdyQaOKKHcpdVIvRR4g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCy8LBqXGBhsU5N0iQ0O7mHbnqHo27evY1VjVRZ/Tx1zgIgBffQJXYQQdFKH7xqqdzTYaewk8Ro+oMOdFHSQ3kyzqE="}]}},"1.1.1":{"name":"require-new","description":"Requires a new module object.","keywords":["require","module","cache","reload","test"],"version":"1.1.1","main":"src/index.js","author":{"name":"Gajus Kuizinas","email":"gk@anuary.com"},"repository":{"type":"git","url":"git+https://github.com/gajus/require-new.git"},"license":"BSD-3-Clause","scrips":{"test":"gulp test"},"devDependencies":{"chai":"^3.2.0","gitdown":"^1.3.2","gulp":"^3.9.0","gulp-eslint":"^1.0.0","gulp-mocha":"^2.1.3"},"dependencies":{"stack-trace":"^0.0.9"},"gitHead":"7fa47ddd48633a3a87fdc4669611f6ab4688fc86","bugs":{"url":"https://github.com/gajus/require-new/issues"},"homepage":"https://github.com/gajus/require-new#readme","_id":"require-new@1.1.1","scripts":{},"_shasum":"6e3af05a690f5624609dd34c273c906586dbf1c5","_from":".","_npmVersion":"4.0.2","_nodeVersion":"7.1.0","_npmUser":{"name":"gajus","email":"gajus@gajus.com"},"dist":{"shasum":"6e3af05a690f5624609dd34c273c906586dbf1c5","tarball":"https://registry.npmjs.org/require-new/-/require-new-1.1.1.tgz","integrity":"sha512-+wPF2OirbMoUL1i8rRHyhCSOK0WBvSANynjxXW5Lnfc1Ws55k/XdftUTfYQv1mxtyXugZ9lAYNp2sDvgQzq2gg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCzW4VxlxHhH27pBRr9Rw3+JiLivB8kqerXYnuqfSJCkgIgCZWRuVIALaCv5b7YMVHgApXf+9XtrUnlcZSSeFAlttc="}]},"maintainers":[{"name":"gajus","email":"gk@anuary.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/require-new-1.1.1.tgz_1479811714114_0.8288117793854326"},"deprecated":"Deprecated in favour of require-uncached package."}},"readme":"## DEPRECATED\n\nDeprecated in favour of [require-uncached](https://github.com/sindresorhus/require-uncached).\n\nFor deprecation reason, see https://github.com/sindresorhus/require-uncached/issues/4.\n\ntl;dr; avoiding duplication of effort in the open-source world.\n\n<h2 id=\"require-new\">require-new</h2>\n\n[![Travis build status](http://img.shields.io/travis/gajus/require-new/master.svg?style=flat)](https://travis-ci.org/gajus/require-new)\n[![NPM version](http://img.shields.io/npm/v/require-new.svg?style=flat)](https://www.npmjs.org/package/require-new)\n\n> Modules are cached after the first time they are loaded. This means (among other things) that every call to require('foo') will get exactly the same object returned, if it would resolve to the same file.\n\n– http://nodejs.org/api/modules.html#modules_caching\n\n`require-new` requires a new module object.\n\n`require-new` does not affect the state or behavior of `require` method.\n\n`require-new` has been designed to be used for module testing.\n\n<h2 id=\"usage\">Usage</h2>\n\nLoad `require-new` module and use it to load a module just as you would with `require`:\n\n```js\nvar requireNew = require('require-new'),\n    myModule = requireNew('my-module');\n```\n\n<h3 id=\"usage-example\">Example</h3>\n\nIf you have a module `rand.js`:\n\n```js\nmodule.exports = Math.random();\n```\n\nThen requiring this module several times will result in the same response:\n\n```js\nrequire('./rand.js'); // 0.697190385311842\nrequire('./rand.js'); // 0.697190385311842\n```\n\nModules are cached in a [`require.cache`](http://nodejs.org/api/globals.html#globals_require_cache) object when they are required.\n\n`require-new` deletes the key value from the `require.cache` object associated with the module you are requesting, making the module reload:\n\n```js\nrequireNew('./rand.js'); // 0.2123227424453944\nrequireNew('./rand.js'); // 0.5403654584661126\n```\n\nIt then restores the state of the `require.cache` object to ensure that it does not affect the behavior of `require`:\n\n```js\nrequire('./rand.js'); // 0.48205413995310664\nrequireNew('./rand.js'); // 0.12475096038542688\nrequireNew('./rand.js'); // 0.2615479789674282\nrequire('./rand.js'); // 0.48205413995310664\n```\n\n<h2 id=\"alternative-design\">Alternative Design</h2>\n\nYou can export a function and call that function. This will make the module execute code multiple times.\n\n```js\nmodule.exports = function () {\n    return Math.random();\n};\n```\n\n```js\nrequire('rand.js')(); // 0.561616780469194\nrequire('rand.js')(); // 0.6468832329846919\n```\n\nSee discussion on [Stack Overflow](http://stackoverflow.com/questions/9210542/node-js-require-cache-possible-to-invalidate/11477602) to consider the pros and cons.\n\n<h2 id=\"download\">Download</h2>\n\nDownload using NPM:\n\n```sh\nnpm install require-new\n```\n","maintainers":[{"email":"gajus@gajus.com","name":"gajus"}],"time":{"modified":"2022-06-26T11:39:02.348Z","created":"2014-11-15T10:43:19.022Z","1.0.0":"2014-11-15T10:43:19.022Z","1.0.1":"2014-11-15T11:24:21.884Z","1.0.2":"2014-11-15T12:09:25.437Z","1.1.0":"2015-08-18T11:09:55.653Z","1.1.1":"2016-11-22T10:48:34.693Z"},"homepage":"https://github.com/gajus/require-new#readme","keywords":["require","module","cache","reload","test"],"repository":{"type":"git","url":"git+https://github.com/gajus/require-new.git"},"author":{"name":"Gajus Kuizinas","email":"gk@anuary.com"},"bugs":{"url":"https://github.com/gajus/require-new/issues"},"license":"BSD-3-Clause","readmeFilename":"README.md"}