1 | import isObject from './isObject';
|
2 |
|
3 | /** `Object#toString` result references. */
|
4 | var regexpTag = '[object RegExp]';
|
5 |
|
6 | /** Used for built-in method references. */
|
7 | var objectProto = Object.prototype;
|
8 |
|
9 | /**
|
10 | * Used to resolve the
|
11 | * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
|
12 | * of values.
|
13 | */
|
14 | var objectToString = objectProto.toString;
|
15 |
|
16 | /**
|
17 | * Checks if `value` is classified as a `RegExp` object.
|
18 | *
|
19 | * @static
|
20 | * @memberOf _
|
21 | * @since 0.1.0
|
22 | * @category Lang
|
23 | * @param {*} value The value to check.
|
24 | * @returns {boolean} Returns `true` if `value` is correctly classified,
|
25 | * else `false`.
|
26 | * @example
|
27 | *
|
28 | * _.isRegExp(/abc/);
|
29 | * // => true
|
30 | *
|
31 | * _.isRegExp('/abc/');
|
32 | * // => false
|
33 | */
|
34 | function isRegExp(value) {
|
35 | return isObject(value) && objectToString.call(value) == regexpTag;
|
36 | }
|
37 |
|
38 | export default isRegExp;
|