mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 00:27:50 +00:00
wip: migrate to bun
This commit is contained in:
30
src/isTypedArray.ts
Normal file
30
src/isTypedArray.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import getTag from './.internal/getTag.js';
|
||||
import nodeTypes from './.internal/nodeTypes.js';
|
||||
import isObjectLike from './isObjectLike.js';
|
||||
|
||||
/** Used to match `toStringTag` values of typed arrays. */
|
||||
const reTypedTag = /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/;
|
||||
|
||||
/* 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;
|
||||
Reference in New Issue
Block a user