{"name":"require-at","version":"1.0.5","main":"require-at.js","description":"Call require pretending your are at another directory","scripts":{"test":"mocha test/spec","coverage":"istanbul cover -- _mocha test/spec && istanbul check-coverage"},"keywords":[],"author":{"name":"Joel Chen"},"license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/jchip/require-at.git"},"dependencies":{},"devDependencies":{"chai":"^3.5.0","istanbul":"^0.4.5","mocha":"^3.2.0"},"engines":{"node":">=4"},"gitHead":"20845e1fba6e6e2c25e8114359a317eea7f385f3","bugs":{"url":"https://github.com/jchip/require-at/issues"},"homepage":"https://github.com/jchip/require-at#readme","_id":"require-at@1.0.5","_nodeVersion":"14.15.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-UdlXej5ii6Vyt0uFMMJUpLzGLlONGC6thLZGiaT8jZjQBLA0D+xSV00ozbadrU6wjTH+mNxuguEKHQURWt5DBQ==","shasum":"459a741039c69c2c87c49269d1d2efe12254405e","tarball":"http://registry-npm.ywwl.com/require-at/download/require-at-1.0.5.tgz","fileCount":3,"unpackedSize":4542,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfwgrKCRA9TVsSAnZWagAA5twP/06Hra3ElXCAGo5jcxYD\n1adtfC9PelbRdNXoJjVt0TKaJ0aSTQy9tMSUP7L/3cg4xq/JBZAlRaxELF49\nO6/6zKsTLg55q2qNEtzdF7YPtacyKU/GfijpE0iuyLSTDOyfyHeebqs3WzQS\nQullYfireYpNg8rAyVdPQH4uw55rZo8IRoxDTvnXJiTZJWtOsNqhDJ5UQKvP\nNffN4dYxXm8UhHs7v6/kNcdZ0qDdsa6fuJII3ctxbLRNUKtfQct29aYUFbx5\nK5wHRiUy++ncv8LUpSmNGK5ZeMkWuMTVs8VJf2a3jRitFQ0D52/P4JVliDDT\nt/MQQHG9QmVQU77hyLRfrHfchvTGjgDx+zLkT4tZ6x1ag0Bz8GfJu7Fhzvgm\n1/8Wphpzie5jznGI1jompAQsraOa9dYBA5IFMCwPyoFGT+wVN3B7waBH8FYv\nbtIgOA5Hov0p7/jToGOwoarWqBqWWDloV+12y8/z6UAy2tPGAms2hAECtd/n\n/ZrVUoJkX8KtdpZLO70kDuwKB2klw3PMVztBISdjMj5mw5+6Ou9uFfAraxzV\nYylVYFUJ5vsNTeZF43njfAjTYz0R8Uvg14xjwHZV3SYaIPheIas+CE+xj8GI\nEOxs5Sc3Mqg+qaPAmf14qU6CpZrgMm03WXD3xm2uWRIk3Jw0Sdxs+UwX3m39\nH3nR\r\n=/Z7Y\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGGqAqwmNJjKcbytkG6GWnbIdESyubBFVF1upxaxK+Q0AiBOhdRuYk4P0AzmimRcrEPhGawNykRMFIOrMTqWNjpUJQ=="}],"size":1949,"noattachment":false,"key":"/require-at/-/require-at-1.0.5.tgz"},"_npmUser":{"name":"jchip","email":"joel123@gmail.com"},"directories":{},"maintainers":[{"name":"jchip","email":"joel123@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/require-at_1.0.5_1606552265985_0.3242504490816538"},"_hasShrinkwrap":false,"readme":"[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]\n[![Dependency Status][daviddm-image]][daviddm-url] [![devDependency Status][daviddm-dev-image]][daviddm-dev-url]\n\n# require-at\n\nAllow you to call `require` or `require.resolve` pretending that you are at another directory.\n\n## Purpose\n\nGiven the directory structure below with two NodeJS apps:\n\n    app1\n    |-+ foo\n    | +-- index.js\n    | +--+ node_modules\n    |    +--+ x \n    |       + ...\n    app2\n    |-+ bar\n    | +-- index.js\n    | +--+ node_modules\n    |    +--+ y\n    |       + ...\n\nWhen you call `require(\"x\")` in `/app1/foo/index.js`, NodeJS will search and find module `x` there.\n\nNow from the same file, if you want to resolve the module `y` under the directory `/app2/bar`, you have to use an absolute or relative path directly pointing to `y`, and you may have to do some searching, probably re-implementing Node's module searching algorithm if you don't know exactly where `y` could be.\n\nHowever, in the file `/app2/bar/index.js`, it can just do `require(\"y\")` and Node would automatically find the module for it, because that file is at the location where `y` is under.\n\nWhat if from the file `/app1/foo/index.js`, you can call `require` as if you were at the directory `/app2/bar`, then you would be able to utilize Node's module searching automatically. \n\nTo achieve this, most other implementations choose to re-implement Node's module searching algorithm.\n\nThis module's approach is to tap into Node's `module` and let it do the work.\n\n## Install\n\n    $ npm install require-at --save\n\n## Usage\n\nA single function is exported.\n\n##### `requireAt(dir, [request])`\n\n-   If you call it with just `dir`, then it returns a `require` function that's been binded to the directory `dir`.  You can use it to load any module as if you are at `dir`.  \n    -   You can also call `require.resolve` with the same effect.\n-   If you call it with `dir` and a `request`, then it will load and return the module `request` as if at `dir`.\n\n##### Example\n\n```js\nconst requireAt = require(\"require-at\");\n\n// get back a require binded to /another/dir\n\nconst requireAtAnother = requireAt(\"/another/dir/\");\nconst modXPath = requireAtAnother.resolve(\"modX\");\nconst modX = requireAtAnother(\"modX\");\n\n// load modY at /another/yet/dir directly\n\nconst modY = requireAt(\"/another/yet/dir\", \"modY\");\n```\n\n## License\n\nApache-2.0 © [Joel Chen](https://github.com/jchip)\n\n[travis-image]: https://travis-ci.org/jchip/require-at.svg?branch=master\n\n[travis-url]: https://travis-ci.org/jchip/require-at\n\n[npm-image]: https://badge.fury.io/js/require-at.svg\n\n[npm-url]: https://npmjs.org/package/require-at\n\n[daviddm-image]: https://david-dm.org/jchip/require-at/status.svg\n\n[daviddm-url]: https://david-dm.org/jchip/require-at\n\n[daviddm-dev-image]: https://david-dm.org/jchip/require-at/dev-status.svg\n\n[daviddm-dev-url]: https://david-dm.org/jchip/require-at?type=dev\n","publish_time":1606552266135,"_cnpm_publish_time":1606552266135,"dist-tags":{"latest":"1.0.6"}}