@se-oss/regexp-escape
v1.0.0
Published
Isomorphic Stage 4 RegExp.escape polyfill
Maintainers
Readme
@se-oss/regexp-escape is an isomorphic Stage 4 RegExp.escape polyfill that brings the latest TC39 specification to your environment today.
📦 Installation
npm install @se-oss/regexp-escapepnpm
pnpm install @se-oss/regexp-escapeyarn
yarn add @se-oss/regexp-escape📖 Usage
Ponyfill
Import and use directly without modifying globals:
import escape from '@se-oss/regexp-escape';
const escaped = escape('a.b*c');
console.log(escaped); // "\\x61\\x2eb\\*c"Polyfill
Automatically patch the native RegExp object:
import '@se-oss/regexp-escape/polyfill';
// Now available globally
const escaped = RegExp.escape('a.b*c');📚 Documentation
For more information, please see the TC39 RegExp.escape proposal or the API docs.
🚀 Performance
| Library | Operations/sec | | -------------------------------------- | -------------- | | Native | ~813,507 | | @se-oss/regexp-escape (isomorphic) | ~790,797 | | @se-oss/regexp-escape (pollyfill) | ~177,705 | | regexp.escape | ~41,153 |
Benchmark script: bench/index.bench.ts
🤝 Contributing
Want to contribute? Awesome! To show your support is to star the project, or to raise issues on GitHub.
Thanks again for your support, it is much appreciated! 🙏
License
MIT © Shahrad Elahi and contributors.
