sfcode An Online Competing and Development Environment

RegExp

RegExp instance

# <tt>reg-exp/is</tt>

Confirms if given object is a native regular expression object

const isRegExp = require("type/reg-exp/is");
isRegExp(/foo/);
isRegExp({}); // false
isRegExp("foo"); // false

# <tt>reg-exp/ensure</tt>

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