{"name":"regexpu-core","version":"4.8.0","description":"regexpu’s core functionality (i.e. `rewritePattern(pattern, flag)`), capable of translating ES6 Unicode regular expressions to ES5.","homepage":"https://mths.be/regexpu","main":"rewrite-pattern.js","engines":{"node":">=4"},"keywords":["codegen","desugaring","ecmascript","es5","es6","harmony","javascript","refactoring","regex","regexp","regular expressions","rewriting","syntax","transformation","transpile","transpiler","unicode"],"license":"MIT","author":{"name":"Mathias Bynens","url":"https://mathiasbynens.be/"},"repository":{"type":"git","url":"git+https://github.com/mathiasbynens/regexpu-core.git"},"bugs":{"url":"https://github.com/mathiasbynens/regexpu-core/issues"},"scripts":{"build":"node scripts/iu-mappings.js && node scripts/character-class-escape-sets.js","test":"mocha tests","cover":"istanbul cover --report html node_modules/.bin/_mocha tests -- -u exports -R spec"},"dependencies":{"regenerate":"^1.4.2","regenerate-unicode-properties":"^9.0.0","regjsgen":"^0.5.2","regjsparser":"^0.7.0","unicode-match-property-ecmascript":"^2.0.0","unicode-match-property-value-ecmascript":"^2.0.0"},"devDependencies":{"codecov":"^3.8.3","istanbul":"^0.4.5","jsesc":"^3.0.2","lodash":"^4.17.21","mocha":"^9.1.1","regexpu-fixtures":"2.1.4","@unicode/unicode-14.0.0":"^1.2.1"},"gitHead":"ebf17f04db64a20ce74902c18144e915b82183b9","_id":"regexpu-core@4.8.0","_nodeVersion":"16.9.1","_npmVersion":"7.21.1","dist":{"integrity":"sha512-1F6bYsoYiz6is+oz70NWur2Vlh9KWtswuRuzJOfeYUrfPX2o8n74AnUVaOGDbUqVGO9fNHu48/pjJO4sNVwsOg==","shasum":"e5605ba361b67b1718478501327502f4479a98f0","tarball":"http://registry-npm.ywwl.com/regexpu-core/download/regexpu-core-4.8.0.tgz","fileCount":6,"unpackedSize":34331,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhQIgKCRA9TVsSAnZWagAA5k8P/3KmvUhGUwpgpXd4fvBE\nS/FRNruAxVx3S7V+PChrVbtlHJ9h7vB6/Z7AecqNYckRstZwKQbUwFJrjt/0\n3QDdz1rBpzQMaVyqQAEaQ3acMzNe/ASacTP+RdGozNZAORnIt6/lpkfDe/mO\nfrd+8CzrtsTFrlPwuOL4bAYYSBvqBFSE4UM8ltBc8cSkNpwHJ16xsCgR//7V\nCGHpoyu3KeGaNS1R4Oow513Umlp1DZ6vWyTxJwkF/yKy3K1h4rFJicnvUPvK\nVqKTpvjZArWvrclADu7Lo8iu6j5wxEXA3khgXAW81yI+mdU1LqkQEdezRIgK\nMiK6M67SMmCdrZr89qpoWtxTKR6aLkqFkL7ppFG1d1l7aEkEahJ8xki5Lsk3\nzbRvPoAySBNqwQlWohTLt9R72gzlUrNzmwX8qGPE5YIukX1tNfLiBZ8QYoHY\ncsH4GjWop9PwNKYGKukFeAeYDvq0MMH8BHF1OgM6l1aEgJ8HnbReBAwoatF+\neyhHSJuMQoS0I3C3e3bSqcNOt/UDtkN+c2UH7vocjt7Ep4RzzvKsnnuZw2CR\n2jZgdyL3hPdAYNJJj++qcfad6j+GLTTNzpxeR4Ku8F7Urh72aP+DnNBB5YMz\n3emLYFDrkgkVsBdx4a1wYyhWOu0vHw5+p/Pk7dgBSJgCXxUn7k40jB3nCRF8\nWfCu\r\n=bg4O\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFYdaVnlg0X/EaM+U6WcawvKHJhz21HGdSmzxGPT+oQpAiEApIzH+Dz1R6xPq0JBftdctOjKNy35wGM6syk/8X/Vxas="}],"size":10129,"noattachment":false,"key":"/regexpu-core/-/regexpu-core-4.8.0.tgz"},"_npmUser":{"name":"google-wombot","email":"node-team-npm+wombot@google.com"},"directories":{},"maintainers":[{"name":"mathias","email":"mathias@qiwi.be"},{"name":"jridgewell","email":"justin+npm@ridgewell.name"},{"name":"nicolo-ribaudo","email":"nicolo.ribaudo@gmail.com"},{"name":"google-wombot","email":"node-team-npm+wombot@google.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/regexpu-core_4.8.0_1631619082464_0.6544393656268634"},"_hasShrinkwrap":false,"readme":"# regexpu-core [![Build status](https://github.com/mathiasbynens/regexpu-core/workflows/run-checks/badge.svg)](https://github.com/mathiasbynens/regexpu-core/actions?query=workflow%3Arun-checks) [![regexpu-core on npm](https://img.shields.io/npm/v/regexpu-core)](https://www.npmjs.com/package/regexpu-core)\n\n_regexpu_ is a source code transpiler that enables the use of ES2015 Unicode regular expressions in JavaScript-of-today (ES5).\n\n_regexpu-core_ contains _regexpu_’s core functionality, i.e. `rewritePattern(pattern, flag)`, which enables rewriting regular expressions that make use of [the ES2015 `u` flag](https://mathiasbynens.be/notes/es6-unicode-regex) into equivalent ES5-compatible regular expression patterns.\n\n## Installation\n\nTo use _regexpu-core_ programmatically, install it as a dependency via [npm](https://www.npmjs.com/):\n\n```bash\nnpm install regexpu-core --save\n```\n\nThen, `require` it:\n\n```js\nconst rewritePattern = require('regexpu-core');\n```\n\n## API\n\nThis module exports a single function named `rewritePattern`.\n\n### `rewritePattern(pattern, flags, options)`\n\nThis function takes a string that represents a regular expression pattern as well as a string representing its flags, and returns an ES5-compatible version of the pattern.\n\n```js\nrewritePattern('foo.bar', 'u', { unicodeFlag: \"transform\" });\n// → 'foo(?:[\\\\0-\\\\t\\\\x0B\\\\f\\\\x0E-\\\\u2027\\\\u202A-\\\\uD7FF\\\\uDC00-\\\\uFFFF]|[\\\\uD800-\\\\uDBFF][\\\\uDC00-\\\\uDFFF]|[\\\\uD800-\\\\uDBFF])bar'\n\nrewritePattern('[\\\\u{1D306}-\\\\u{1D308}a-z]', 'u', { unicodeFlag: \"transform\" });\n// → '(?:[a-z]|\\\\uD834[\\\\uDF06-\\\\uDF08])'\n\nrewritePattern('[\\\\u{1D306}-\\\\u{1D308}a-z]', 'ui', { unicodeFlag: \"transform\" });\n// → '(?:[a-z\\\\u017F\\\\u212A]|\\\\uD834[\\\\uDF06-\\\\uDF08])'\n```\n\n_regexpu-core_ can rewrite non-ES6 regular expressions too, which is useful to demonstrate how their behavior changes once the `u` and `i` flags are added:\n\n```js\n// In ES5, the dot operator only matches BMP symbols:\nrewritePattern('foo.bar', '', { unicodeFlag: \"transform\" });\n// → 'foo(?:[\\\\0-\\\\t\\\\x0B\\\\f\\\\x0E-\\\\u2027\\\\u202A-\\\\uFFFF])bar'\n\n// But with the ES2015 `u` flag, it matches astral symbols too:\nrewritePattern('foo.bar', 'u', { unicodeFlag: \"transform\" });\n// → 'foo(?:[\\\\0-\\\\t\\\\x0B\\\\f\\\\x0E-\\\\u2027\\\\u202A-\\\\uD7FF\\\\uDC00-\\\\uFFFF]|[\\\\uD800-\\\\uDBFF][\\\\uDC00-\\\\uDFFF]|[\\\\uD800-\\\\uDBFF])bar'\n```\n\nThe optional `options` argument recognizes the following properties:\n\n#### Stable regular expression features\n\nThese options can be set to `false` or `'transform'`. When using `'transform'`, the corresponding features are compiled to older syntax that can run in older browsers. When using `false` (the default), they are not compiled and they can be relied upon to compile more modern features.\n\n- `unicodeFlag` - The `u` flag, enabling support for Unicode code point escapes in the form `\\u{...}`.\n\n  ```js\n  rewritePattern('\\\\u{ab}', '', {\n    unicodeFlag: 'transform'\n  });\n  // → '\\\\u{ab}'\n\n  rewritePattern('\\\\u{ab}', 'u', {\n    unicodeFlag: 'transform'\n  });\n  // → '\\\\xAB'\n  ```\n\n- `dotAllFlag` - The [`s` (`dotAll`) flag](https://github.com/mathiasbynens/es-regexp-dotall-flag).\n\n  ```js\n  rewritePattern('.', '', {\n    dotAllFlag: 'transform'\n  });\n  // → '[\\\\0-\\\\t\\\\x0B\\\\f\\\\x0E-\\\\u2027\\\\u202A-\\\\uFFFF]'\n\n  rewritePattern('.', 's', {\n    dotAllFlag: 'transform'\n  });\n  // → '[\\\\0-\\\\uFFFF]'\n\n  rewritePattern('.', 'su', {\n    dotAllFlag: 'transform'\n  });\n  // → '(?:[\\\\0-\\\\uD7FF\\\\uE000-\\\\uFFFF]|[\\\\uD800-\\\\uDBFF][\\\\uDC00-\\\\uDFFF]|[\\\\uD800-\\\\uDBFF](?![\\\\uDC00-\\\\uDFFF])|(?:[^\\\\uD800-\\\\uDBFF]|^)[\\\\uDC00-\\\\uDFFF])'\n  ```\n\n- `unicodePropertyEscapes` - [Unicode property escapes](property-escapes.md).\n\n  By default they are compiled to Unicode code point escapes of the form `\\u{...}`. If the `unicodeFlag` option is set to `'transform'` they often result in larger output, although there are cases (such as `\\p{Lu}`) where it actually _decreases_ the output size.\n\n  ```js\n  rewritePattern('\\\\p{Script_Extensions=Anatolian_Hieroglyphs}', 'u', {\n    unicodePropertyEscapes: 'transform'\n  });\n  // → '[\\\\u{14400}-\\\\u{14646}]'\n\n  rewritePattern('\\\\p{Script_Extensions=Anatolian_Hieroglyphs}', 'u', {\n    unicodeFlag: 'transform',\n    unicodePropertyEscapes: 'transform'\n  });\n  // → '(?:\\\\uD811[\\\\uDC00-\\\\uDE46])'\n  ```\n\n- `namedGroups` - [Named capture groups](https://github.com/tc39/proposal-regexp-named-groups).\n\n  ```js\n  rewritePattern('(?<name>.)\\\\k<name>', '', {\n    namedGroups: 'transform'\n  });\n  // → '(.)\\1'\n  ```\n\n- `unicodeSetsFlag` - [The `v` (`unicodeSets`) flag](https://github.com/tc39/proposal-regexp-set-notation)\n\n  ```js\n  rewritePattern('[\\\\p{Emoji}&&\\\\p{ASCII}]', 'v', {\n    unicodeSetsFlag: 'transform'\n  });\n  // → '[#\\\\*0-9]'\n  ```\n\n  By default, patterns with the `v` flag are transformed to patterns with the `u` flag. If you want to downlevel them more you can set the `unicodeFlag: 'transform'` option.\n\n  ```js\n  rewritePattern('[^[a-h]&&[f-z]]', 'v', {\n    unicodeSetsFlag: 'transform'\n  });\n  // → '[^f-h]' (to be used with /u)\n  ```\n\n  ```js\n  rewritePattern('[^[a-h]&&[f-z]]', 'v', {\n    unicodeSetsFlag: 'transform',\n    unicodeFlag: 'transform'\n  });\n  // → '(?:(?![f-h])[\\s\\S])' (to be used without /u)\n  ```\n\n#### Experimental regular expression features\n\nThese options can be set to `false`, `'parse'` and `'transform'`. When using `'transform'`, the corresponding features are compiled to older syntax that can run in older browsers. When using `'parse'`, they are parsed and left as-is in the output pattern. When using `false` (the default), they result in a syntax error if used.\n\nOnce these features become stable (when the proposals are accepted as part of ECMAScript), they will be parsed by default and thus `'parse'` will behave like `false`.\n\n- `modifiers` - [Inline `m`/`s`/`i` modifiers](https://github.com/tc39/proposal-regexp-modifiers)\n\n  ```js\n  rewritePattern('(?i:[a-z])[a-z]', '', {\n    modifiers: 'transform'\n  });\n  // → '(?:[a-zA-Z])([a-z])'\n  ```\n\n#### Miscellaneous options\n\n- `onNamedGroup`\n\n  This option is a function that gets called when a named capture group is found. It receives two parameters:\n  the name of the group, and its index.\n\n  ```js\n  rewritePattern('(?<name>.)\\\\k<name>', '', {\n    onNamedGroup(name, index) {\n      console.log(name, index);\n      // → 'name', 1\n    }\n  });\n  ```\n\n- `onNewFlags`\n\n  This option is a function that gets called to pass the flags that the resulting pattern must be interpreted with.\n\n  ```js\n  rewritePattern('abc', 'um', '', {\n    unicodeFlag: 'transform',\n    onNewFlags(flags) {\n      console.log(flags);\n      // → 'm'\n    }\n  })\n  ```\n\n### Caveats\n\n- [Lookbehind assertions](https://github.com/tc39/proposal-regexp-lookbehind) cannot be transformed to older syntax.\n- When using `namedGroups: 'transform'`, _regexpu-core_ only takes care of the _syntax_: you will still need a runtime wrapper around the regular expression to populate the `.groups` property of `RegExp.prototype.match()`'s result. If you are using _regexpu-core_ via Babel, it's handled automatically.\n\n## For maintainers\n\n### How to publish a new release\n\n1. On the `main` branch, bump the version number in `package.json`:\n\n    ```sh\n    npm version patch -m 'Release v%s'\n    ```\n\n    Instead of `patch`, use `minor` or `major` [as needed](https://semver.org/).\n\n    Note that this produces a Git commit + tag.\n\n1. Push the release commit and tag:\n\n    ```sh\n    git push --follow-tags\n    ```\n\n    Our CI then automatically publishes the new release to npm.\n\n1. Once the release has been published to npm, update [`regexpu`](https://github.com/mathiasbynens/regexpu) to make use of it, and [cut a new release of `regexpu` as well](https://github.com/mathiasbynens/regexpu#how-to-publish-a-new-release).\n\n\n## Author\n\n| [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias \"Follow @mathias on Twitter\") |\n|---|\n| [Mathias Bynens](https://mathiasbynens.be/) |\n\n## License\n\n_regexpu-core_ is available under the [MIT](https://mths.be/mit) license.\n","publish_time":1631619082583,"_cnpm_publish_time":1631619082583,"dist-tags":{"latest":"6.5.4"}}