{"_id":"@astra-mod/pirates","_rev":"2-f4910ad9bd82650229070089ce14f231","name":"@astra-mod/pirates","dist-tags":{"latest":"4.2.0"},"versions":{"4.1.0":{"name":"@astra-mod/pirates","description":"Properly hijack require","main":"lib/index.js","version":"4.1.0","types":"index.d.ts","scripts":{"clean":"rimraf lib","build":"babel src -d lib","test":"cross-env BABEL_ENV=test yarn run build && nyc ava","lint":"eslint --report-unused-disable-directives .","prepare-publish":"node scripts/preparePublish.js"},"repository":{"type":"git","url":"git+https://github.com/Astra-mod/pirate.git"},"engines":{"node":">= 6"},"author":{"name":"Ari Porad","email":"ari@ariporad.com","url":"http://ariporad.com"},"devDependencies":{"@babel/cli":"^7.0.0","@babel/core":"^7.0.0","@babel/preset-env":"^7.0.0","ava":"^1.2.1","babel-core":"^7.0.0-0","babel-eslint":"^10.0.1","babel-plugin-istanbul":"^5.1.0","cross-env":"^5.0.5","cz-conventional-changelog":"^2.0.0","decache":"^4.1.0","eslint":"^5.1.0","eslint-config-prettier":"^4.0.0","eslint-plugin-import":"^2.2.0","eslint-plugin-prettier":"^3.0.1","mock-require":"^3.0.2","nyc":"^13.2.0","prettier":"^1.16.4","rewire":"^4.0.1","rimraf":"^2.6.1"},"license":"MIT","bugs":{"url":"https://github.com/Astra-mod/pirate/issues"},"homepage":"https://github.com/Astra-mod/pirate#readme","config":{"commitizen":{"path":"cz-conventional-changelog"}},"ava":{"files":["test/*.js"],"sources":["lib/**/*.js"]},"nyc":{"include":["src/*.js"],"reporter":["json","text"],"sourceMap":false,"instrument":false},"gitHead":"38522bbd372ee09c26d81330c0f6d2e4512d471e","_id":"@astra-mod/pirates@4.1.0","_nodeVersion":"15.14.0","_npmVersion":"7.7.6","dist":{"integrity":"sha512-kv3GgNmmOs0OhhMVxvqcFD/jAAiICbMsO8mlnNJNuqIiYi5QIQiml61ubTddhECa00fiDE7B2oMfLeVClMxIkg==","shasum":"c781c3dac2d561a74e116e43cb2c9a1beb0cdde1","tarball":"https://registry.npmjs.org/@astra-mod/pirates/-/pirates-4.1.0.tgz","fileCount":5,"unpackedSize":14772,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhvhEUCRA9TVsSAnZWagAAyocP/2p6uEHEE3a1WAtNXvlQ\nNg3FpsWKLbyGd7MjlETotXY3c7llLF0PSSjBjRzePQ3M7qpQTar0JMTlRL4g\nDt0/lwolYIQvUBQuStH133viQLJnj3LGfdmD+ZKYc9Bpsg/uw9OTAC3xZzJk\nQ4POhvJxJQgqaN/nsBNzm5pnU9u8VDhu2a7pyl+l5azTMvoG3SLWLt2qrTxN\nAk76xd64efPMBHx+WaiJmGEpSerHg4yYrdQIAkEYoFkzjWDP3rU4cWVKcnOw\nZOWoXcH9GTT6IuH4Oq4gyLFKuzvsPsTqW8mxKY4idBPtlDBG4dOZon3oKoLB\nrNMnnpRsTagK0PE17aFixAxntIy9V0z6XWkZa1iEynG/F0BNPIG3Z3DouBw7\nuxlEOCK0848ZzHWlvY9Om0rw9qH4hl0yCkHWckh3aUF+ggFQwv59OJR1TPLM\ngw2WnOMetQz4gWWFO0I9Y0lk9Y0LdPAtaLJFbUe9a7DAXY06LYdRYxxX0GrB\nKZeFlQyRNuohGkRkxuxXIw4fbVMu345VKgSngWwn6IUGdEb/v/bRUJ9TsuYq\nynoJXx2ipfVpjf5+Tenem5P+rvvhPwptcZ35ArDih0G6P/frYAh8CFbSubHk\nCTPldk81dd2YPLBjFwXRm6RUXP0o18Id59N/7/mgIe6vX1fUPlMJUYVqhN+t\nMXI9\r\n=Cf+P\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDH/qWCKiY4vSONUMR4uRNYbOxYPXyhU2+qjRTqvPztcwIhAOoD+8XY1l5yyqAnG/xEBrGhHusoUwjDKfwkbP3bsMWl"}]},"_npmUser":{"name":"1lighty","email":"zt7vt43q1@relay.firefox.com"},"directories":{},"maintainers":[{"name":"1lighty","email":"zt7vt43q1@relay.firefox.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pirates_4.1.0_1639846164146_0.9763257013457933"},"_hasShrinkwrap":false},"4.2.0":{"name":"@astra-mod/pirates","description":"Properly hijack require","main":"lib/index.js","version":"4.2.0","types":"index.d.ts","scripts":{"clean":"rimraf lib","build":"babel src -d lib","test":"cross-env BABEL_ENV=test yarn run build && nyc ava","lint":"eslint --report-unused-disable-directives .","prepare-publish":"node scripts/preparePublish.js"},"repository":{"type":"git","url":"git+https://github.com/Astra-mod/pirate.git"},"engines":{"node":">= 6"},"author":{"name":"Ari Porad","email":"ari@ariporad.com","url":"http://ariporad.com"},"devDependencies":{"@babel/cli":"7.18.10","@babel/core":"7.18.10","@babel/preset-env":"7.18.10","@babel/register":"^7.18.9","ava":"^4.3.1","babel-core":"7.0.0-bridge.0","babel-eslint":"10.1.0","babel-plugin-istanbul":"5.2.0","cross-env":"5.2.1","decache":"4.6.1","eslint":"5.16.0","eslint-config-prettier":"4.3.0","eslint-plugin-import":"2.26.0","eslint-plugin-prettier":"3.4.1","mock-require":"3.0.3","nyc":"^15.1.0","prettier":"1.19.1","rewire":"^6.0.0","rimraf":"3.0.2"},"license":"MIT","bugs":{"url":"https://github.com/Astra-mod/pirate/issues"},"homepage":"https://github.com/Astra-mod/pirate#readme","config":{"commitizen":{"path":"cz-conventional-changelog"}},"ava":{"files":["test/*.js"],"require":["@babel/register"]},"nyc":{"include":["src/*.js"],"reporter":["json","text"],"sourceMap":false,"instrument":false},"gitHead":"ad49ce746e038b7606711efb3dcfb2fefeeb7b97","_id":"@astra-mod/pirates@4.2.0","_nodeVersion":"16.16.0","_npmVersion":"8.11.0","dist":{"integrity":"sha512-qcBgWQ525TLLyLLdGKbbPy1FEX1t0vK+uncPIIMlDrPJmTd2hc+uHz1334VUZ1lwh5I4uHZ7ihVz3/5jXqqEYw==","shasum":"820165dc8f007a9064d17ec3561e50a1fa61d99e","tarball":"https://registry.npmjs.org/@astra-mod/pirates/-/pirates-4.2.0.tgz","fileCount":5,"unpackedSize":14935,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHZm0qb97xA5fH9m+jZv90qPXQXpQskoDJnvxfCss/l4AiEAuq3SfIGpnnkF/zYU8QsTl89tWCvZB+BxybFw31yqq0w="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi+TjJACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmriXw//WtbOfbo3OgQvCqUN1T3DTtVVOqxgTe0vC5u7BDeackdkYFsW\r\nb1KgYesbNbKFW4iZyD/RwV9+EAtf3yAbnzDY6JkYKHJFg9V/yWSbwiI3Bjgw\r\nkt8VBl4cYakCkUfb0shFOONb9id85VKtcKs5sKWJqoLvJKvVv9W4WZ5i8W/l\r\n1XeKiopMT7MvJ7mKHu5m3XqYu+Zfev6Y5mlpe/KfWDCPOvL+Px4z1FJHvKKv\r\nERRtkqJQgCXpjEkE6qxHJvbFHkB9iyeFs3EwUsIyCN37XGisXe+gI81Gt7EQ\r\nDVf3UY9N/VBghArJx5uiIbIqaiwYzCbNYpUDZ/cZfDwz6cHFhWRTcd/z+Gq9\r\nFO0kf7VKWQ+D7HR0UA0eOsQlVrbwHwsCApL9cLCuAl+AXGQUc4PGC6Uwexd0\r\nLms6a/gvS3R5g3qO8+FakUq6thzZjv9oh5AgvipAzdPFRFaEhHcAt09waKTc\r\n4J2FOpuv+xJxG1bOn+hwtNYrNnem8oObh26Pvo24vOj41x/fBst5mTR06G14\r\nFAAAqLvteDuAOtaO0uiEm6wQNbcTaCl/g6B3puNn2HzhtKe4e6fRCa7kB0pO\r\nD88dW9B6MW8GnRQv0itgfTXcCzwYDSp01ED6pYvdXje5mHcAYCTmIn1hLnRc\r\n0gcHnQvON1CwqpWlEzZKH6WnkvIjlCew6EM=\r\n=h0MP\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"1lighty","email":"zt7vt43q1@relay.firefox.com"},"directories":{},"maintainers":[{"name":"1lighty","email":"zt7vt43q1@relay.firefox.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pirates_4.2.0_1660500169159_0.34303390729380157"},"_hasShrinkwrap":false}},"time":{"created":"2021-12-18T16:49:24.076Z","4.1.0":"2021-12-18T16:49:24.319Z","modified":"2022-08-14T18:02:49.406Z","4.2.0":"2022-08-14T18:02:49.330Z"},"maintainers":[{"name":"1lighty","email":"zt7vt43q1@relay.firefox.com"}],"description":"Properly hijack require","homepage":"https://github.com/Astra-mod/pirate#readme","repository":{"type":"git","url":"git+https://github.com/Astra-mod/pirate.git"},"author":{"name":"Ari Porad","email":"ari@ariporad.com","url":"http://ariporad.com"},"bugs":{"url":"https://github.com/Astra-mod/pirate/issues"},"license":"MIT","readme":"**This is a modified version of pirates, only used for a Discord client mod.**  \nChanges include:\n - preHook option, bypasses the original js loader which bypasses the call to fs.readFileSync\n   as well as bypasses the passed hook itself\n\n### Properly hijack require\n\n## Why?\n\nTwo reasons:\n1. Babel and istanbul were breaking each other.\n2. Everyone seemed to re-invent the wheel on this, and everyone wanted a solution that was DRY, simple, easy to use,\nand made everything Just Work™, while allowing multiple require hooks, in a fashion similar to calling `super`.\n\nFor some context, see [the Babel issue thread][] which started this all, then [the nyc issue thread][], where\ndiscussion was moved (as we began to discuss just using the code nyc had developed), and finally to [#1][issue-1]\nwhere discussion was finally moved.\n\n[the Babel issue thread]: https://github.com/babel/babel/pull/3062 \"Babel Issue Thread\"\n[the nyc issue thread]: https://github.com/bcoe/nyc/issues/70 \"NYC Issue Thread\"\n[issue-1]: https://github.com/danez/pirates/issues/1 \"Issue #1\"\n\n## Installation\n\n    npm install --save @astra-mod/pirates\n\n## Usage\n\nUsing pirates is really easy:\n```javascript\n// my-module/register.js\nconst addHook = require('@astra-mod/pirates').addHook;\n// Or if you use ES modules\n// import { addHook } from '@astra-mod/pirates';\n\nfunction matcher(filename) {\n  // Here, you can inspect the filename to determine if it should be hooked or\n  // not. Just return a truthy/falsey. Files in node_modules are automatically ignored,\n  // unless otherwise specified in options (see below).\n\n  // TODO: Implement your logic here\n  return true;\n}\n\nconst revert = addHook(\n  (code, filename) => code.replace('@@foo', 'console.log(\\'foo\\');'),\n  { exts: ['.js'], matcher }\n);\n\n// And later, if you want to un-hook require, you can just do:\nrevert();\n```\n\n## API\n\n### pirates.addHook(hook, [opts={ [matcher: true], [exts: ['.js']], [ignoreNodeModules: true] }]);\nAdd a require hook. `hook` must be a function that takes `(code, filename)`, and returns the modified code. `opts` is\nan optional options object. Available options are: `matcher`, which is a function that accepts a filename, and\nreturns a truthy value if the file should be hooked (defaults to a function that always returns true), falsey if\notherwise; `exts`, which is an array of extensions to hook, they should begin with `.` (defaults to `['.js']`);\n`ignoreNodeModules`, if true, any file in a `node_modules` folder wont be hooked (the matcher also wont be called),\nif false, then the matcher will be called for any files in `node_modules` (defaults to true).\n\nAs for the custom prehook property, you will get passed a filename, you can then return a pretranspiled version of\nthat module as a string.\n\n## Projects that use Pirates\n\nSee the [wiki page](https://github.com/danez/pirates/wiki/Projects-using-Pirates). If you add Pirates to your project,\n(And you should! It works best if everyone uses it. Then we can have a happy world full of happy require hooks!), please\nadd yourself to the wiki.\n","readmeFilename":"README.md"}