{"name":"regexpu","version":"4.4.0","description":"A source code transpiler that enables the use of ES2015 Unicode regular expressions in ES5.","homepage":"https://mths.be/regexpu","main":"regexpu.js","engines":{"node":">=4"},"bin":{"regexpu":"bin/regexpu"},"keywords":["codegen","desugaring","ecmascript","es5","es6","es2015","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.git"},"bugs":{"url":"https://github.com/mathiasbynens/regexpu/issues"},"directories":{"bin":"bin","man":"man"},"scripts":{"build":"scripts/build","test":"mocha tests","cover":"istanbul cover --report html node_modules/.bin/_mocha tests/tests.js -- -u exports -R spec"},"dependencies":{"jsesc":"^2.5.2","recast":"^0.16.1","regexpu-core":"^4.4.0"},"devDependencies":{"babili":"0.1.4","browserify":"^16.2.3","codecov":"^3.1.0","istanbul":"^0.4.5","lodash":"^4.17.11","mocha":"^5.2.0","regexpu-fixtures":"^2.1.2"},"man":["/usr/local/google/home/mathiasb/projects/regexpu/man/regexpu.1"],"gitHead":"386b48bd13d27e5a7dcf6e609bba4c5a07c79b06","_id":"regexpu@4.4.0","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"mathias","email":"mathias@qiwi.be"},"dist":{"integrity":"sha512-JB9FfWtbSTYVOy4Ui/TvvNe8idcl2q46dZSGJ8OP9wwRV0jdllyG118pNJp+gZ09fhhoBINF+NPlk6kY8Xad0w==","shasum":"18c916972964c1c5ac4aac2a83b9f4a4af07803c","tarball":"http://registry-npm.ywwl.com/regexpu/download/regexpu-4.4.0.tgz","fileCount":8,"unpackedSize":22261,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcB9GTCRA9TVsSAnZWagAAzVwP/3psIwvcHVvwTAhdV8z0\nWN4+nCQXk13esquujcoa/SIf4z9Y0e59i1q0zQli9PffoxlhOuaIZGGfB5DJ\nQGmDwkhQqU1tGi53TPuK6BLGwbOKttCos1jILl0y6Gu0NGrU0b3mLfzuMi+Q\nLgwrril1/urr9cdJVPH8RyTSZe8VsJIP71wa7L7U5ajBerGApJFxjkCfC+Ll\n5DmLVRnXVot62TfHY6qa36XFe+7rHMM8DSwuhsXU5e8sEnFd3TAjk6Rb4GMF\nCtWj2kWSzGhjZbbv0LA60Frad2OjxeR8J/23fZBIg+Ns9bwvUeAHbwLSTPo6\nnUhvb4/E8rk4ZMgzpOcmx9GQaTrFnZXmmaIkejxBLM7SS9U36+JcCncs+0Kq\nSvkxpDk159bGqU9YsrB6dnakqliy3mhItrxn/GqfIaOBhulmfh7HcjeZcuiz\nVwd0BmCwV+n271sUIu9HQh8uO0TH45qtzlR92a+Jjykm54NXXQN7vZZLI5mn\nYkjv2t5Qpw177WVBWDIAileCprrvzwNgzz8ORnxsT2nKkGWXypfSVP+OF6pE\nAs+q03zIA0kda7cJ8625aU6nYbM/WTVssHRyCQ3XyZX0pfRB9dhCtghv1Mgm\n54IH3K8s/tEDa8S2EujnKktp6IAxM1utTOiAj8Zjhvza+iXsaxmcg2G23KPX\nApkI\r\n=1m3x\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFk0xvnirJrBlO2BWoBYGu1Cfkt9JQn/Oy9W5WI76P7CAiEAmiN/9sKCXFemD/gDTSeRMj/CJ6XMbAqNbqshcXCZhJ4="}],"size":7191,"noattachment":false,"key":"/regexpu/-/regexpu-4.4.0.tgz"},"maintainers":[{"name":"mathias","email":"mathias@qiwi.be"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/regexpu_4.4.0_1544016275090_0.946120720868374"},"_hasShrinkwrap":false,"readme":"# regexpu [![Build status](https://travis-ci.org/mathiasbynens/regexpu.svg?branch=main)](https://travis-ci.org/mathiasbynens/regexpu) [![Code coverage status](https://img.shields.io/codecov/c/github/mathiasbynens/regexpu.svg)](https://codecov.io/gh/mathiasbynens/regexpu) [![regexpu on npm](https://img.shields.io/npm/v/regexpu)](https://www.npmjs.com/package/regexpu)\n\n_regexpu_ is a source code transpiler that enables the use of ES2015 Unicode regular expressions in JavaScript-of-today (ES5). It rewrites regular expressions that make use of [the ES2015 `u` flag](https://mathiasbynens.be/notes/es6-unicode-regex) into equivalent ES5-compatible regular expressions.\n\n[Here’s an online demo.](https://mothereff.in/regexpu)\n\n[Traceur v0.0.61+](https://github.com/google/traceur-compiler), [Babel v1.5.0+](https://github.com/babel/babel), [esnext v0.12.0+](https://github.com/esnext/esnext), and [Bublé v0.12.0+](https://buble.surge.sh/) use _regexpu_ for their `u` regexp transpilation. The REPL demos for [Traceur](https://google.github.io/traceur-compiler/demo/repl.html#%2F%2F%20Traceur%20now%20uses%20regexpu%20%28https%3A%2F%2Fmths.be%2Fregexpu%29%20to%20transpile%20regular%0A%2F%2F%20expression%20literals%20that%20have%20the%20ES2015%20%60u%60%20flag%20set%20into%20equivalent%20ES5.%0A%0A%2F%2F%20Match%20any%20symbol%20from%20U%2B1F4A9%20PILE%20OF%20POO%20to%20U%2B1F4AB%20DIZZY%20SYMBOL.%0Avar%20regex%20%3D%20%2F%5B%F0%9F%92%A9-%F0%9F%92%AB%5D%2Fu%3B%20%2F%2F%20Or%2C%20%60%2F%5Cu%7B1F4A9%7D-%5Cu%7B1F4AB%7D%2Fu%60.%0Aconsole.log%28%0A%20%20regex.test%28'%F0%9F%92%A8'%29%2C%20%2F%2F%20false%0A%20%20regex.test%28'%F0%9F%92%A9'%29%2C%20%2F%2F%20true%0A%20%20regex.test%28'%F0%9F%92%AA'%29%2C%20%2F%2F%20true%0A%20%20regex.test%28'%F0%9F%92%AB'%29%2C%20%2F%2F%20true%0A%20%20regex.test%28'%F0%9F%92%AC'%29%20%20%2F%2F%20false%0A%29%3B%0A%0A%2F%2F%20See%20https%3A%2F%2Fmathiasbynens.be%2Fnotes%2Fes6-unicode-regex%20for%20more%20examples%20and%0A%2F%2F%20info.%0A), [Babel](https://babeljs.io/repl/#?experimental=true&playground=true&evaluate=true&code=%2F%2F%20Babel%20now%20uses%20regexpu%20%28https%3A%2F%2Fmths.be%2Fregexpu%29%20to%20transpile%20regular%0A%2F%2F%20expression%20literals%20that%20have%20the%20ES2015%20%60u%60%20flag%20set%20into%20equivalent%20ES5.%0A%0A%2F%2F%20Match%20any%20symbol%20from%20U%2B1F4A9%20PILE%20OF%20POO%20to%20U%2B1F4AB%20DIZZY%20SYMBOL.%0Avar%20regex%20%3D%20%2F%5B%F0%9F%92%A9-%F0%9F%92%AB%5D%2Fu%3B%20%2F%2F%20Or%2C%20%60%2F%5Cu%7B1F4A9%7D-%5Cu%7B1F4AB%7D%2Fu%60.%0Aconsole.log%28%0A%20%20regex.test%28'%F0%9F%92%A8'%29%2C%20%2F%2F%20false%0A%20%20regex.test%28'%F0%9F%92%A9'%29%2C%20%2F%2F%20true%0A%20%20regex.test%28'%F0%9F%92%AA'%29%2C%20%2F%2F%20true%0A%20%20regex.test%28'%F0%9F%92%AB'%29%2C%20%2F%2F%20true%0A%20%20regex.test%28'%F0%9F%92%AC'%29%20%20%2F%2F%20false%0A%29%3B%0A%0A%2F%2F%20See%20https%3A%2F%2Fmathiasbynens.be%2Fnotes%2Fes6-unicode-regex%20for%20more%20examples%20and%0A%2F%2F%20info.%0A), [esnext](https://esnext.github.io/esnext/#%2F%2F%20esnext%20now%20uses%20regexpu%20%28https%3A%2F%2Fmths.be%2Fregexpu%29%20to%20transpile%20regular%0A%2F%2F%20expression%20literals%20that%20have%20the%20ES2015%20%60u%60%20flag%20set%20into%20equivalent%20ES5.%0A%0A%2F%2F%20Match%20any%20symbol%20from%20U%2B1F4A9%20PILE%20OF%20POO%20to%20U%2B1F4AB%20DIZZY%20SYMBOL.%0Avar%20regex%20%3D%20%2F%5B%F0%9F%92%A9-%F0%9F%92%AB%5D%2Fu%3B%20%2F%2F%20Or%2C%20%60%2F%5Cu%7B1F4A9%7D-%5Cu%7B1F4AB%7D%2Fu%60.%0Aconsole.log%28%0A%20%20regex.test%28'%F0%9F%92%A8'%29%2C%20%2F%2F%20false%0A%20%20regex.test%28'%F0%9F%92%A9'%29%2C%20%2F%2F%20true%0A%20%20regex.test%28'%F0%9F%92%AA'%29%2C%20%2F%2F%20true%0A%20%20regex.test%28'%F0%9F%92%AB'%29%2C%20%2F%2F%20true%0A%20%20regex.test%28'%F0%9F%92%AC'%29%20%20%2F%2F%20false%0A%29%3B%0A%0A%2F%2F%20See%20https%3A%2F%2Fmathiasbynens.be%2Fnotes%2Fes6-unicode-regex%20for%20more%20examples%20and%0A%2F%2F%20info.%0A), and [Bublé](https://buble.surge.sh/#%2F%2F%20Bubl%C3%A9%20now%20uses%20regexpu%20%28https%3A%2F%2Fmths.be%2Fregexpu%29%20to%20transpile%20regular%0A%2F%2F%20expression%20literals%20that%20have%20the%20ES2015%20%60u%60%20flag%20set%20into%20equivalent%20ES5.%0A%0A%2F%2F%20Match%20any%20symbol%20from%20U%2B1F4A9%20PILE%20OF%20POO%20to%20U%2B1F4AB%20DIZZY%20SYMBOL.%0Avar%20regex%20%3D%20%2F%5B%F0%9F%92%A9-%F0%9F%92%AB%5D%2Fu%3B%20%2F%2F%20Or%2C%20%60%2F%5Cu%7B1F4A9%7D-%5Cu%7B1F4AB%7D%2Fu%60.%0Aconsole.log%28%0A%20%20regex.test%28'%F0%9F%92%A8'%29%2C%20%2F%2F%20false%0A%20%20regex.test%28'%F0%9F%92%A9'%29%2C%20%2F%2F%20true%0A%20%20regex.test%28'%F0%9F%92%AA'%29%2C%20%2F%2F%20true%0A%20%20regex.test%28'%F0%9F%92%AB'%29%2C%20%2F%2F%20true%0A%20%20regex.test%28'%F0%9F%92%AC'%29%20%20%2F%2F%20false%0A%29%3B%0A%0A%2F%2F%20See%20https%3A%2F%2Fmathiasbynens.be%2Fnotes%2Fes6-unicode-regex%20for%20more%20examples%0A%2F%2F%20and%20info.%0A) let you try `u` regexps as well as other ES.next features.\n\n## Example\n\nConsider a file named `example-es2015.js` with the following contents:\n\n```js\nvar string = 'foo💩bar';\nvar match = string.match(/foo(.)bar/u);\nconsole.log(match[1]);\n// → '💩'\n\n// This regex matches any symbol from U+1F4A9 to U+1F4AB, and nothing else.\nvar regex = /[\\u{1F4A9}-\\u{1F4AB}]/u;\n// The following regex is equivalent.\nvar alternative = /[💩-💫]/u;\nconsole.log([\n  regex.test('a'),  // false\n  regex.test('💩'), // true\n  regex.test('💪'), // true\n  regex.test('💫'), // true\n  regex.test('💬')  // false\n]);\n```\n\nLet’s transpile it:\n\n```bash\n$ regexpu < example-es2015.js > example-es5.js\n```\n\n`example-es5.js` can now be used in ES5 environments. Its contents are as follows:\n\n```js\nvar string = 'foo💩bar';\nvar match = string.match(/foo((?:[\\0-\\t\\x0B\\f\\x0E-\\u2027\\u202A-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]))bar/);\nconsole.log(match[1]);\n// → '💩'\n\n// This regex matches any symbol from U+1F4A9 to U+1F4AB, and nothing else.\nvar regex = /(?:\\uD83D[\\uDCA9-\\uDCAB])/;\n// The following regex is equivalent.\nvar alternative = /(?:\\uD83D[\\uDCA9-\\uDCAB])/;\nconsole.log([\n  regex.test('a'),  // false\n  regex.test('💩'), // true\n  regex.test('💪'), // true\n  regex.test('💫'), // true\n  regex.test('💬')  // false\n]);\n```\n\n## Known limitations\n\n1. _regexpu_ only transpiles regular expression _literals_, so things like `RegExp('…', 'u')` are not affected.\n2. _regexpu_ doesn’t polyfill [the `RegExp.prototype.unicode` getter](https://mths.be/es6#sec-get-regexp.prototype.unicode) because it’s not possible to do so without side effects.\n3. _regexpu_ doesn’t support [canonicalizing the contents of back-references in regular expressions with both the `i` and `u` flag set](https://github.com/mathiasbynens/regexpu/issues/4), since that would require transpiling/wrapping strings.\n4. _regexpu_ [doesn’t match lone low surrogates accurately](https://github.com/mathiasbynens/regexpu/issues/17). Unfortunately that is impossible to implement due to the lack of lookbehind support in JavaScript regular expressions.\n\n## Installation\n\nTo use _regexpu_ programmatically, install it as a dependency via [npm](https://www.npmjs.com/):\n\n```bash\nnpm install regexpu --save-dev\n```\n\nTo use the command-line interface, install _regexpu_ globally:\n\n```bash\nnpm install regexpu -g\n```\n\n## API\n\n### `regexpu.version`\n\nA string representing the semantic version number.\n\n### `regexpu.rewritePattern(pattern, flags, options)`\n\nThis is an alias for the `rewritePattern` function exported by [_regexpu-core_](https://github.com/mathiasbynens/regexpu-core). Please refer to that project’s documentation for more information.\n\n`regexpu.rewritePattern` uses [regjsgen](https://github.com/d10/regjsgen), [regjsparser](https://github.com/jviereck/regjsparser), and [regenerate](https://github.com/mathiasbynens/regenerate) as internal dependencies. If you only need this function in your program, it’s better to include it directly:\n\n```js\n// Instead of…\nconst rewritePattern = require('regexpu').rewritePattern;\n\n// Use this:\nconst rewritePattern = require('regexpu-core');\n```\n\nThis prevents the [Recast](https://github.com/benjamn/recast) and [Esprima](https://github.com/ariya/esprima) dependencies from being loaded into memory.\n\n### `regexpu.transformTree(ast, options)` or its alias `regexpu.transform(ast, options)`\n\nThis function accepts an abstract syntax tree representing some JavaScript code, and returns a transformed version of the tree in which any regular expression literals that use the ES2015 `u` flag are rewritten in ES5.\n\n```js\nconst regexpu = require('regexpu');\nconst recast = require('recast');\nconst tree = recast.parse(code); // ES2015 code\nconst transformedTree = regexpu.transform(tree);\nconst result = recast.print(transformedTree);\nconsole.log(result.code); // transpiled ES5 code\nconsole.log(result.map); // source map\n```\n\nThe optional `options` object is passed to _regexpu-core_’s `rewritePattern`. For a description of the available options, [see its documentation](https://github.com/mathiasbynens/regexpu-core#rewritepatternpattern-flags-options).\n\n`regexpu.transformTree` uses [Recast](https://github.com/benjamn/recast), [regjsgen](https://github.com/d10/regjsgen), [regjsparser](https://github.com/jviereck/regjsparser), and [regenerate](https://github.com/mathiasbynens/regenerate) as internal dependencies. If you only need this function in your program, it’s better to include it directly:\n\n```js\nconst transformTree = require('regexpu/transform-tree');\n```\n\nThis prevents the [Esprima](https://github.com/ariya/esprima) dependency from being loaded into memory.\n\n### `regexpu.transpileCode(code, options)`\n\nThis function accepts a string representing some JavaScript code, and returns a transpiled version of this code tree in which any regular expression literals that use the ES2015 `u` flag are rewritten in ES5.\n\n```js\nconst es2015 = 'console.log(/foo.bar/u.test(\"foo💩bar\"));';\nconst es5 = regexpu.transpileCode(es2015);\n// → 'console.log(/foo(?:[\\\\0-\\\\t\\\\x0B\\\\f\\\\x0E-\\\\u2027\\\\u202A-\\\\uD7FF\\\\uDC00-\\\\uFFFF]|[\\\\uD800-\\\\uDBFF][\\\\uDC00-\\\\uDFFF]|[\\\\uD800-\\\\uDBFF])bar/.test(\"foo💩bar\"));'\n```\n\nThe optional `options` object recognizes the following properties:\n\n* `sourceFileName`: a string representing the file name of the original ES2015 source file.\n* `sourceMapName`: a string representing the desired file name of the source map.\n* `dotAllFlag`: a boolean indicating whether to enable [experimental support for the `s` (`dotAll`) flag](https://github.com/mathiasbynens/es-regexp-dotall-flag).\n* `unicodePropertyEscape`: a boolean indicating whether to enable [experimental support for Unicode property escapes](https://github.com/mathiasbynens/regexpu-core/blob/master/property-escapes.md).\n\nThe `sourceFileName` and `sourceMapName` properties must be provided if you want to generate source maps.\n\n```js\nconst result = regexpu.transpileCode(code, {\n  'sourceFileName': 'es2015.js',\n  'sourceMapName': 'es2015.js.map',\n});\nconsole.log(result.code); // transpiled source code\nconsole.log(result.map); // source map\n```\n\n`regexpu.transpileCode` uses [Esprima](https://github.com/ariya/esprima), [Recast](https://github.com/benjamn/recast), [regjsgen](https://github.com/d10/regjsgen), [regjsparser](https://github.com/jviereck/regjsparser), and [regenerate](https://github.com/mathiasbynens/regenerate) as internal dependencies. If you only need this function in your program, feel free to include it directly:\n\n```js\nconst transpileCode = require('regexpu/transpile-code');\n```\n\n## Transpilers that use regexpu internally\n\nIf you’re looking for a general-purpose ES.next-to-ES5 transpiler with support for Unicode regular expressions, consider using one of these:\n\n* [Traceur](https://github.com/google/traceur-compiler) v0.0.61+\n* [Babel](https://github.com/babel/babel) v1.5.0+\n* [esnext](https://github.com/esnext/esnext) v0.12.0+\n* [Bublé](https://gitlab.com/Rich-Harris/buble) v0.12.0+\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 && git push --tags\n    ```\n\n    Our CI then automatically publishes the new release to npm.\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_ is available under the [MIT](https://mths.be/mit) license.\n","publish_time":1544016275181,"_cnpm_publish_time":1544016275181,"dist-tags":{"latest":"4.8.0"}}