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