Files
lodash/isTypedArray.js
Joyee Cheung 363fef0efc internal: use util.types to migrate DEP0103 in Node.js (#3704)
- Use require('util').types instead of using process.binding('util')
  to get the type checking helpers
- Rename nodeUtil to nodeTypes since that is what it is for

Refs: https://github.com/nodejs/node/pull/18415
2018-03-23 07:31:36 -07:00

31 lines
872 B
JavaScript

import getTag from './.internal/getTag.js'
import nodeTypes from './.internal/nodeTypes.js'
import isObjectLike from './isObjectLike'
/** Used to match `toStringTag` values of typed arrays. */
const reTypedTag = /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)\]$/
/* Node.js helper references. */
const nodeIsTypedArray = nodeTypes && nodeTypes.isTypedArray
/**
* Checks if `value` is classified as a typed array.
*
* @since 3.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
* @example
*
* isTypedArray(new Uint8Array)
* // => true
*
* isTypedArray([])
* // => false
*/
const isTypedArray = nodeIsTypedArray
? (value) => nodeIsTypedArray(value)
: (value) => isObjectLike(value) && reTypedTag.test(getTag(value))
export default isTypedArray