6d912b2649ac3d5c43529ddd1f7b058f378dbfd00a57679d534efde9c6d587ce8861a2fae6bf83b9d9d6b246e346941f48f2f01ab48cdb2c6077c615ee065a 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # safe-regex-test <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
  2. [![github actions][actions-image]][actions-url]
  3. [![coverage][codecov-image]][codecov-url]
  4. [![License][license-image]][license-url]
  5. [![Downloads][downloads-image]][downloads-url]
  6. [![npm badge][npm-badge-png]][package-url]
  7. Give a regex, get a robust predicate function that tests it against a string. This will work even if `RegExp.prototype` is altered later.
  8. ## Getting started
  9. ```sh
  10. npm install --save safe-regex-test
  11. ```
  12. ## Usage/Examples
  13. ```js
  14. var regexTester = require('safe-regex-test');
  15. var assert = require('assert');
  16. var tester = regexTester('a');
  17. assert.ok(tester('a'));
  18. assert.notOk(tester('b'));
  19. ```
  20. ## Tests
  21. Simply clone the repo, `npm install`, and run `npm test`
  22. [package-url]: https://npmjs.org/package/safe-regex-test
  23. [npm-version-svg]: https://versionbadg.es/ljharb/safe-regex-test.svg
  24. [deps-svg]: https://david-dm.org/ljharb/safe-regex-test.svg
  25. [deps-url]: https://david-dm.org/ljharb/safe-regex-test
  26. [dev-deps-svg]: https://david-dm.org/ljharb/safe-regex-test/dev-status.svg
  27. [dev-deps-url]: https://david-dm.org/ljharb/safe-regex-test#info=devDependencies
  28. [npm-badge-png]: https://nodei.co/npm/safe-regex-test.png?downloads=true&stars=true
  29. [license-image]: https://img.shields.io/npm/l/safe-regex-test.svg
  30. [license-url]: LICENSE
  31. [downloads-image]: https://img.shields.io/npm/dm/safe-regex-test.svg
  32. [downloads-url]: https://npm-stat.com/charts.html?package=safe-regex-test
  33. [codecov-image]: https://codecov.io/gh/ljharb/safe-regex-test/branch/main/graphs/badge.svg
  34. [codecov-url]: https://app.codecov.io/gh/ljharb/safe-regex-test/
  35. [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/safe-regex-test
  36. [actions-url]: https://github.com/ljharb/safe-regex-test/actions