Socket
Socket
Sign inDemoInstall

is-regex

Package Overview
Dependencies
0
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
30M
decreased by-9.03%
Maintainers
1
Install size
17.3 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.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

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 30 Jan 2015

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