2.0.7 • Published 4 months ago

@zerodep/is-regex v2.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

@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
2.0.7

4 months ago

2.0.6

4 months ago

2.0.5

4 months ago

2.0.2

12 months ago

2.0.4

9 months ago

2.0.1

1 year ago