{"_id":"@cjser/super-regex__v0_2_0","name":"@cjser/super-regex__v0_2_0","dist-tags":{"latest":"0.2.0-cjser.2"},"versions":{"0.2.0-cjser.2":{"name":"@cjser/super-regex__v0_2_0","version":"0.2.0-cjser.2","description":"Make a regular expression time out if it takes too long to execute","license":"MIT","repository":{"type":"git","url":"https://code.moenext.com/3rdeye/cjser.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"require":"./dist-cjser/index.cjs","default":"./index.js"},"types":"./index.d.ts","engines":{"node":">=14.16"},"scripts":{"test":"xo && ava && tsd"},"keywords":["regex","regexp","regular","expression","timeout","time","out","cancel","expire","abort","redos","security","script","execute"],"dependencies":{"@cjser/clone-regexp":"3.0.0-cjser.2","@cjser/function-timeout__v0_1_1":"0.1.1-cjser.2","@cjser/time-span":"5.1.0-cjser.2"},"devDependencies":{"ava":"^4.3.0","tsd":"^0.20.0","xo":"^0.49.0"},"main":"./dist-cjser/index.cjs","cjser":{"sourceVersion":"0.2.0","cjserVersion":2,"original":{"name":"super-regex","version":"0.2.0","exports":"./index.js","repository":"sindresorhus/super-regex","dependencies":{"clone-regexp":"^3.0.0","function-timeout":"^0.1.0","time-span":"^5.1.0"},"files":["index.js","index.d.ts"],"scripts":{"test":"xo && ava && tsd"}}},"_id":"@cjser/super-regex__v0_2_0@0.2.0-cjser.2","gitHead":"0168e4aac54a1a9ca6f921419fa5ed9edb53ef4a","_nodeVersion":"20.14.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-jVJP8fBEVtC/vM0YQQlHBRDAaxWqa+tXsh4HirZ2ONW5azBRuXyP+fmI4wtCryLj3EPgQ44G0smGHRX6jmyT6g==","shasum":"38c0aaf332cb28018aee030d6ab9c7300ffd1301","tarball":"https://registry.npmjs.org/@cjser/super-regex__v0_2_0/-/super-regex__v0_2_0-0.2.0-cjser.2.tgz","fileCount":6,"unpackedSize":13111,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBAFEgquMkSI5u+89W0JG2JCE9+moKJWA4bFbZXNZl71AiEA2K7PlX/iv61LLaoG3gFK9GMWtBScrjW9xskmpw7UWtU="}]},"_npmUser":{"name":"nanahira","email":"nanahira@momobako.com"},"directories":{},"maintainers":[{"name":"nanahira","email":"nanahira@momobako.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/super-regex__v0_2_0_0.2.0-cjser.2_1778131072105_0.5374712185808697"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-07T05:17:52.036Z","0.2.0-cjser.2":"2026-05-07T05:17:52.278Z","modified":"2026-05-07T05:17:52.506Z"},"maintainers":[{"name":"nanahira","email":"nanahira@momobako.com"}],"description":"Make a regular expression time out if it takes too long to execute","keywords":["regex","regexp","regular","expression","timeout","time","out","cancel","expire","abort","redos","security","script","execute"],"repository":{"type":"git","url":"https://code.moenext.com/3rdeye/cjser.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"license":"MIT","readme":"# super-regex\n\n> Make a regular expression time out if it takes too long to execute\n\nThis can be used to prevent [ReDoS vulnerabilities](https://en.wikipedia.org/wiki/ReDoS) when running a regular expression against untrusted user input.\n\nThis package also has a better API than the built-in regular expression methods. For example, none of the methods mutate the regex.\n\nThe timeout only works in Node.js. In the browser, it will simply not time out.\n\n## Install\n\n```sh\nnpm install super-regex\n```\n\n## Usage\n\n```js\nimport {isMatch} from 'super-regex';\n\nconsole.log(isMatch(/\\d+/, getUserInput(), {timeout: 1000}));\n```\n\n## API\n\n### isMatch(regex, string, options?)\n\nReturns a boolean for whether the given `regex` matches the given `string`.\n\nIf the regex takes longer to match than the given timeout, it returns `false`.\n\n*This method is similar to [`RegExp#test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test), but differs in that the given `regex` is [never mutated, even when it has the `/g` flag](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test#using_test_on_a_regex_with_the_global_flag).*\n\n### firstMatch(regex, string, options?)\n\nReturns the first `Match` or `undefined` if there was no match.\n\nIf the regex takes longer to match than the given timeout, it returns `undefined`.\n\n### matches(regex, string, options?)\n\nReturns an iterable of `Match`es.\n\nIf the regex takes longer to match than the given timeout, it returns an empty array.\n\n**The `regex` must have the `/g` flag.**\n\n#### options\n\nType: `object`\n\n##### timeout?\n\nType: `number` *(integer)*\n\nThe time in milliseconds to wait before timing out.\n\n##### matchTimeout?\n\nType: `number` *(integer)*\n\nOnly works in `matches()`.\n\nThe time in milliseconds to wait before timing out when searching for each match.\n\n### Match\n\n```ts\n{\n\tmatch: string;\n\tindex: number;\n\tgroups: string[];\n\tnamedGroups: {string: string}; // object with string values\n\tinput: string;\n}\n```\n\n## Related\n\n- [function-timeout](https://github.com/sindresorhus/function-timeout) - Make a synchronous function have a timeout\n\n## cjser\n\nThis package is a CommonJS-compatible build generated by cjser for projects that still need `require()` support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.\nOriginal repository: https://github.com/sindresorhus/super-regex\n","readmeFilename":"readme.md","_rev":"1-512a6e6ce8e5e227a84b15314f763931"}