You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #is-regex <sup>[![Version Badge][2]][1]</sup>
  2. [![Build Status][3]][4]
  3. [![dependency status][5]][6]
  4. [![dev dependency status][7]][8]
  5. [![License][license-image]][license-url]
  6. [![Downloads][downloads-image]][downloads-url]
  7. [![npm badge][11]][1]
  8. [![browser support][9]][10]
  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]: http://versionbadg.es/ljharb/is-regex.svg
  31. [3]: https://travis-ci.org/ljharb/is-regex.svg
  32. [4]: https://travis-ci.org/ljharb/is-regex
  33. [5]: https://david-dm.org/ljharb/is-regex.svg
  34. [6]: https://david-dm.org/ljharb/is-regex
  35. [7]: https://david-dm.org/ljharb/is-regex/dev-status.svg
  36. [8]: https://david-dm.org/ljharb/is-regex#info=devDependencies
  37. [9]: https://ci.testling.com/ljharb/is-regex.png
  38. [10]: https://ci.testling.com/ljharb/is-regex
  39. [11]: https://nodei.co/npm/is-regex.png?downloads=true&stars=true
  40. [license-image]: http://img.shields.io/npm/l/is-regex.svg
  41. [license-url]: LICENSE
  42. [downloads-image]: http://img.shields.io/npm/dm/is-regex.svg
  43. [downloads-url]: http://npm-stat.com/charts.html?package=is-regex