all files / montage/core/extras/ regexp.js

100% Statements 4/4
50% Branches 1/2
100% Functions 1/1
100% Lines 4/4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30                                      368×              
/**
 * @external RegExp
 */
 
/**
 * Returns whether the given value is a regexp, regardless of which context it
 * comes from.
 * The context may be another frame.
 *
 * This is the proper idiomatic way to test whether an object is a regexp and
 * replaces the less generally useful `instanceof` check (which does not work
 * across contexts) and the strangeness that the `typeof` a regexp is
 * `"object"`.
 *
 * @function external:RegExp.isRegExp
 * @param value any value
 * @returns {boolean} whether the given value is a regexp
 */
Eif (!RegExp.isRegExp) {
    var toString = Object.prototype.toString;
    Object.defineProperty(RegExp, "isRegExp", {
        value: function (obj) {
            return toString.call(obj) === "[object RegExp]";
        },
        writable: true,
        configurable: true
    });
}