Skip to content

Latest commit

 

History

History
26 lines (17 loc) · 551 Bytes

reg-exp.md

File metadata and controls

26 lines (17 loc) · 551 Bytes

RegExp

RegExp instance

reg-exp/is

Confirms if given object is a native regular expression object

const isRegExp = require("type/reg-exp/is");

isRegExp(/foo/);
isRegExp({}); // false
isRegExp("foo"); // false

reg-exp/ensure

If given argument is a regular expression object, it is returned back. Otherwise TypeError is thrown.

const ensureRegExp = require("type/reg-exp/ensure");

ensureRegExp(/foo/); // /foo/
ensureRegExp("foo"); // Thrown TypeError: null is not a regular expression object