Socket
Socket
Sign inDemoInstall

is-regex

Package Overview
Dependencies
1
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-regex

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


Version published
Weekly downloads
24M
decreased by-25.9%
Maintainers
1
Install size
52.6 kB
Created
Weekly downloads
 

Package description

What is is-regex?

The is-regex npm package is a utility for checking if a value is a regular expression. It is primarily used to determine whether a given value is an instance of a RegExp object.

What are is-regex's main functionalities?

Check if a value is a RegExp

This feature allows you to verify if a value is a regular expression by returning a boolean result. It's useful when you need to ensure that a variable contains a valid RegExp object before performing operations that are specific to regular expressions.

const isRegex = require('is-regex');

console.log(isRegex(/abc/)); // true
console.log(isRegex('abc')); // false

Other packages similar to is-regex

Changelog

Source

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

Readme

Source

#is-regex Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

browser support

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

Keywords

FAQs

Last updated on 15 Dec 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc