ead2553d919c739c0c65ac6247225ca58c1cf4ed97d9054c562e7897ff93e8e234fbc9b204327e363e40f3372b25beb704b16ccb636c29d28a920ca4059ca9 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # is-regex <sup>[![Version Badge][2]][1]</sup>
  2. [![github actions][actions-image]][actions-url]
  3. [![coverage][codecov-image]][codecov-url]
  4. [![dependency status][5]][6]
  5. [![dev dependency status][7]][8]
  6. [![License][license-image]][license-url]
  7. [![Downloads][downloads-image]][downloads-url]
  8. [![npm badge][11]][1]
  9. Is this value a JS regex?
  10. This module works cross-realm/iframe, and despite ES6 @@toStringTag.
  11. ## Example
  12. ```js
  13. var isRegex = require('is-regex');
  14. var assert = require('assert');
  15. assert.notOk(isRegex(undefined));
  16. assert.notOk(isRegex(null));
  17. assert.notOk(isRegex(false));
  18. assert.notOk(isRegex(true));
  19. assert.notOk(isRegex(42));
  20. assert.notOk(isRegex('foo'));
  21. assert.notOk(isRegex(function () {}));
  22. assert.notOk(isRegex([]));
  23. assert.notOk(isRegex({}));
  24. assert.ok(isRegex(/a/g));
  25. assert.ok(isRegex(new RegExp('a', 'g')));
  26. ```
  27. ## Tests
  28. Simply clone the repo, `npm install`, and run `npm test`
  29. [1]: https://npmjs.org/package/is-regex
  30. [2]: https://versionbadg.es/inspect-js/is-regex.svg
  31. [5]: https://david-dm.org/inspect-js/is-regex.svg
  32. [6]: https://david-dm.org/inspect-js/is-regex
  33. [7]: https://david-dm.org/inspect-js/is-regex/dev-status.svg
  34. [8]: https://david-dm.org/inspect-js/is-regex#info=devDependencies
  35. [11]: https://nodei.co/npm/is-regex.png?downloads=true&stars=true
  36. [license-image]: https://img.shields.io/npm/l/is-regex.svg
  37. [license-url]: LICENSE
  38. [downloads-image]: https://img.shields.io/npm/dm/is-regex.svg
  39. [downloads-url]: https://npm-stat.com/charts.html?package=is-regex
  40. [codecov-image]: https://codecov.io/gh/inspect-js/is-regex/branch/main/graphs/badge.svg
  41. [codecov-url]: https://app.codecov.io/gh/inspect-js/is-regex/
  42. [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-regex
  43. [actions-url]: https://github.com/inspect-js/is-regex/actions