@zerodep/is-regex
TypeScript icon, indicating that this package has built-in type declarations

2.0.7 • Public • Published

@zerodep/is-regex

version language types license

CodeFactor Known Vulnerabilities

A simple, performant utility to determine if a value is a regular expression.

Full documentation is available at the zerodep.app page.

Examples

All @zerodep packages support both ESM and CJS.

import { isRegex } from '@zerodep/is-regex';
// or
const { isRegex } = require('@zerodep/is-regex');

Positive Response

isRegex(/[regex]+/gi); // true
isRegex(new RegExp('$[a-c]{2}]', 'gi')); // true

Negative Response

isRegex(['a', 'b', 'c']); // false
isRegex(1000n); // false
isRegex(true); // false
isRegex(new Date()); // false
isRegex(''); // false
isRegex(new Error('message')); // false
isRegex(3.14); // false
isRegex(() => 'function'); // false
isRegex(42); // false
isRegex(
  new Map([
    ['a', 1],
    ['b', 2],
  ])
); // false
isRegex(null); // false
isRegex({ an: 'object' }); // false
isRegex(new Promise(() => {})); // false
isRegex(new Set([1, 2, 3])); // false
isRegex('a string'); // false
isRegex(Symbol()); // false
isRegex(new Int32Array(2)); // false
isRegex(undefined); // false

Readme

Keywords

Package Sidebar

Install

npm i @zerodep/is-regex

Homepage

zerodep.app

Weekly Downloads

0

Version

2.0.7

License

MIT

Unpacked Size

4.4 kB

Total Files

7

Last publish

Collaborators

  • cdepage