mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
Simplify isType modules.
This commit is contained in:
@@ -1,6 +1,26 @@
|
||||
import baseIsTypedArray from './.internal/baseIsTypedArray.js';
|
||||
import baseGetTag from './.internal/baseGetTag.js';
|
||||
import isLength from './isLength.js';
|
||||
import isObjectLike from './isObjectLike.js';
|
||||
import nodeUtil from './.internal/nodeUtil.js';
|
||||
|
||||
/** Used to identify `toStringTag` values of typed arrays. */
|
||||
const typedArrayTags = {};
|
||||
typedArrayTags['[object Float32Array]'] = typedArrayTags['[object Float64Array]'] =
|
||||
typedArrayTags['[object Int8Array]'] = typedArrayTags['[object Int16Array]'] =
|
||||
typedArrayTags['[object Int32Array]'] = typedArrayTags['[object Uint8Array]'] =
|
||||
typedArrayTags['[object Uint8ClampedArray]'] = typedArrayTags['[object Uint16Array]'] =
|
||||
typedArrayTags['[object Uint32Array]'] = true;
|
||||
|
||||
typedArrayTags['[object AsyncFunction]'] = typedArrayTags['[object Arguments]'] =
|
||||
typedArrayTags['[object Array]'] = typedArrayTags['[object ArrayBuffer]'] =
|
||||
typedArrayTags['[object Boolean]'] = typedArrayTags['[object DataView]'] =
|
||||
typedArrayTags['[object Date]'] = typedArrayTags['[object Error]'] =
|
||||
typedArrayTags['[object Function]'] = typedArrayTags['[object GeneratorFunction]'] =
|
||||
typedArrayTags['[object Map]'] = typedArrayTags['[object Number]'] =
|
||||
typedArrayTags['[object Object]'] = typedArrayTags['[object Proxy]'] =
|
||||
typedArrayTags['[object RegExp]'] = typedArrayTags['[object Set]'] =
|
||||
typedArrayTags['[object String]'] = typedArrayTags['[object WeakMap]'] = false;
|
||||
|
||||
/* Node.js helper references. */
|
||||
const nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
||||
|
||||
@@ -21,6 +41,6 @@ const nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
||||
*/
|
||||
const isTypedArray = nodeIsTypedArray
|
||||
? value => nodeIsTypedArray(value)
|
||||
: baseIsTypedArray;
|
||||
: value => isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
||||
|
||||
export default isTypedArray;
|
||||
|
||||
Reference in New Issue
Block a user