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