Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
27 lines (24 sloc)
692 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import getTag from './.internal/getTag.js' | |
import isObjectLike from './isObjectLike.js' | |
import nodeTypes from './.internal/nodeTypes.js' | |
/* Node.js helper references. */ | |
const nodeIsRegExp = nodeTypes && nodeTypes.isRegExp | |
/** | |
* Checks if `value` is classified as a `RegExp` object. | |
* | |
* @since 0.1.0 | |
* @category Lang | |
* @param {*} value The value to check. | |
* @returns {boolean} Returns `true` if `value` is a regexp, else `false`. | |
* @example | |
* | |
* isRegExp(/abc/) | |
* // => true | |
* | |
* isRegExp('/abc/') | |
* // => false | |
*/ | |
const isRegExp = nodeIsRegExp | |
? (value) => nodeIsRegExp(value) | |
: (value) => isObjectLike(value) && getTag(value) == '[object RegExp]' | |
export default isRegExp |