包详细信息

is-regex

inspect-js197mMIT1.2.1

Is this value a JS regex? Works cross-realm/iframe, and despite ES6 @@toStringTag

regex, regexp, is, regular expression

自述文件

is-regex Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

Is this value a JS regex? This module works cross-realm/iframe, and despite ES6 @@toStringTag.

Example

var isRegex = require('is-regex');
var assert = require('assert');

assert.notOk(isRegex(undefined));
assert.notOk(isRegex(null));
assert.notOk(isRegex(false));
assert.notOk(isRegex(true));
assert.notOk(isRegex(42));
assert.notOk(isRegex('foo'));
assert.notOk(isRegex(function () {}));
assert.notOk(isRegex([]));
assert.notOk(isRegex({}));

assert.ok(isRegex(/a/g));
assert.ok(isRegex(new RegExp('a', 'g')));

Tests

Simply clone the repo, npm install, and run npm test

更新日志

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v1.2.1 - 2024-12-11

Commits

  • [Refactor] use call-bound directly dbabfe3
  • [Deps] update call-bind, gopd d5343a0
  • [Dev Deps] update @arethetypeswrong/cli, @ljharb/tsconfig cc081eb

v1.2.0 - 2024-11-29

Fixed

  • [Tests] allow tests to pass if zero traps are triggered #35

Commits

  • [actions] reuse common workflows be7bf6a
  • [New] add types 39066a4
  • [meta] use npmignore to autogenerate an npmignore file 8938588
  • [Refactor] reorganize code 2f76f26
  • [actions] split out node 10-20, and 20+ 8c9aedf
  • [meta] better eccheck command 6b39408
  • [Dev Deps] update eslint, @ljharb/eslint-config, safe-publish-latest, tape e38cf3c
  • [actions] update codecov uploader 487c75d
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, core-js, foreach, tape 0d7da87
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, core-js, tape c1c1198
  • [actions] update rebase action to use reusable workflow 213646e
  • [Dev Deps] update @ljharb/eslint-config, auto-changelog, core-js, npmignore, tape 0a44e77
  • [Refactor] use hasown d939332
  • [Deps] update call-bind, has-tostringtag 46bfdc9
  • [Tests] use for-each instead of foreach 138b3f2
  • [Tests] replace aud with npm audit 37ed80a
  • [Deps] update gopd 6fd4097
  • [Dev Deps] update core-js 97c1c60
  • [Dev Deps] add missing peer dep 7329b8e

v1.1.4 - 2021-08-05

Commits

  • [Dev Deps] update auto-changelog, core-js, eslint, tape 4b17cad
  • [Refactor] use has-tostringtag to behave correctly in the presence of symbol shams 2dad4af

v1.1.3 - 2021-05-07

Commits

  • [actions] use node/install instead of node/run; use codecov action c681ab9
  • [Fix] do not use Object.prototype.toString when Symbol.toStringTag is shammed ca019fd
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, tape 605a66f
  • [readme] add actions and codecov badges 8d7c6f0
  • [meta] use prepublishOnly script for npm 7+ 8e50e91
  • [Deps] update has-symbols 4742c81

v1.1.2 - 2021-02-01

Commits

  • [Tests] migrate tests to Github Actions cc1686e
  • [readme] fix repo URLs; remove travis badge d1d1da6
  • [meta] do not publish github action workflow files 9f84b99
  • [Tests] run nyc on all tests c37aab9
  • [Robustness] use call-bind fbb61bf
  • [actions] add "Allow Edits" workflow 9022b53
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog d60f28f
  • [Dev Deps] update eslint, @ljharb/eslint-config, tape 2c35c43
  • [actions] switch Automatic Rebase workflow to pull_request_target event 1009e25
  • [meta] gitignore coverage output 3b5fa9e
  • [actions] update workflows 1843ef6

v1.1.1 - 2020-08-03

Commits

  • [Performance] Re-add lastIndex check to improve performance d8495cd
  • [Dev Deps] update auto-changelog, eslint 778fa6b

v1.1.0 - 2020-06-03

Commits

  • [New] use badStringifier‑based RegExp detection 31eff67
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, tape fc91458
  • [Dev Deps] update eslint, @ljharb/eslint-config, tape; add safe-publish-latest d43ed83
  • [Dev Deps] update auto-changelog, tape; add aud 56647d1
  • [meta] only run aud on prod deps e0865b8

v1.0.5 - 2019-12-15

Commits

  • [Tests] use shared travis-ci configs af728b2
  • [Tests] remove jscs 1b8cfe8
  • [meta] add auto-changelog c3131d8
  • [Tests] up to node v8.1, v7.10, v6.11, v4.8; newer npm fails on older nodes 660b658
  • [Tests] up to node v9.3, v8.9, v6.12; use nvm install-latest-npm; pin included builds to LTS 7c25218
  • [Tests] up to node v12.10, v11.15, v10.16, v8.16, v6.17 fa95547
  • [meta] remove unused Makefile and associated utilities 9fd2a29
  • [Tests] up to node v11.3, v10.14, v8.14, v6.15 7f2ac41
  • [Tests] up to node v10.0, v9.11, v8.11, v6.14, v4.9 6fa2b0f
  • [Dev Deps] update eslint, @ljharb/eslint-config 697e1de
  • [actions] add automatic rebasing / merge commit blocking ad86dc9
  • [Dev Deps] update eslint, @ljharb/eslint-config, jscs, nsp, replace, semver, tape 5c99c8e
  • [Dev Deps] update eslint, @ljharb/eslint-config, replace, semver, tape bb63686
  • [Dev Deps] update eslint, @ljharb/eslint-config@, replace, semver, tape ddf3670
  • [Dev Deps] update tape, nsp, eslint, @ljharb/eslint-config e7b5a62
  • [Dev Deps] update eslint, @ljharb/eslint-config, covert, tape c803db5
  • [Tests] switch from nsp to npm audit b7239be
  • [Dev Deps] update eslint, nsp, semver, tape 347ee6c
  • Only apps should have lockfiles. 3866575
  • [Tests] use npx aud instead of nsp or npm audit with hoops d099a39
  • [meta] add funding field 741aecd
  • [Tests] use eclint instead of editorconfig-tools bc6aa75
  • [Tests] on node v10.1 262226f
  • [Dev Deps] update eslint 31fd719
  • [Deps] update has e9e25a3
  • [Dev Deps] update replace aeeb968
  • [Tests] set audit level 2a6290e
  • [Tests] remove nsp fc74c2b

v1.0.4 - 2017-02-18

Fixed

  • [Fix] ensure that lastIndex is not mutated #3

Commits

  • Update eslint, tape, semver; use my personal shared eslint config c4a41c3
  • [Tests] on all node minors; improve test matrix 58d7508
  • [Dev Deps] update tape, jscs, nsp, eslint, @ljharb/eslint-config, semver 7290076
  • Update covert, jscs, eslint, semver dabc729
  • Update eslint a946b05
  • Update tape, jscs, eslint, @ljharb/eslint-config 1744dde
  • [Refactor] when try/catch is needed, bail early if the value lacks an own lastIndex data property. 288ad93
  • Update editorconfig-tools, eslint, semver, replace 4d895c6
  • Update eslint, tape, semver f387f03
  • All grade A-supported node/iojs versions now ship with an npm that understands ^. 55e480f
  • [Dev Deps] update jscs, nsp, eslint, @ljharb/eslint-config, semver 89d9528
  • [Dev Deps] update jscs eb222a8
  • [Tests] up to io.js v3.3, node v4.1 c65429c
  • Update nsp, eslint c60fbd8
  • Update eslint, semver 6a62116
  • [Tests] on node v7.5, v4.7 e764651
  • Test up to io.js v2.1 3bf326a
  • Test on the latest io.js versions. 693d047
  • [Refactor] use an early return instead of a ternary. 31eaca2
  • Test on io.js v2.2 c18c55a
  • Run travis-ci tests on iojs and node v0.12; speed up builds; allow 0.8 failures. a1c237d
  • [Dev Deps] update eslint, @ljharb/eslint-config aa3ea0f
  • [Dev Deps] update eslint, @ljharb/eslint-config d97831d
  • [Dev Deps] Update tape, eslint 95e6def
  • Update eslint, nsp 3844c93
  • Update tape, jscs 0d6dac8
  • Fix tests for faked @@toStringTag 2ebef9f
  • Test up to io.js v3.0 ec1d2d4
  • [Refactor] bail earlier when the value is falsy. a9e333e
  • [Dev Deps] update tape 8cdcaae
  • Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG. 281c4ef
  • Test on io.js v2.4 4d54c68
  • Test on io.js v2.3 23170f5
  • Test on iojs-v1.6 4487ad0

v1.0.3 - 2015-01-29

Commits

  • Update npm run scripts. dc528dd
  • Add toStringTag tests. f48a83a
  • If @@toStringTag is not present, use the old-school Object#toString test. 50b0ffd

v1.0.2 - 2015-01-29

Commits

  • make release a1de7ec
  • Improve optimization by separating the try/catch, and bailing out early when not typeof "object". 5ab7632

v1.0.1 - 2015-01-28

Commits

v1.0.0 - 2014-05-19

Commits

  • Make sure old and unstable nodes don't break Travis 05da747
  • toString is a reserved var name in old Opera 885c48c
  • Updating deps 2ca0e79
  • Updating tape. 9678435
  • Updating covert c3bb898
  • Updating tape 7811708
  • Testing on node 0.6 again dec36ae
  • Run code coverage as part of tests e6f4ebe

v0.0.0 - 2014-01-15

Commits