@zerodep/is-typedarray
v2.0.7
Published
A utility to determine if a value is a Typed Array
Downloads
18
Readme
@zerodep/is-typedarray
A simple, performant utility to determine if a value is a Typed Array.
Full documentation is available at the zerodep.app page.
Examples
All @zerodep packages support both ESM and CJS.
import { isTypedArray } from '@zerodep/is-typedarray';
// or
const { isTypedArray } = require('@zerodep/is-typedarray');
Positive Response
isTypedArray(new Int8Array(2)); // true
isTypedArray(new Uint8Array(2)); // true
isTypedArray(new Uint8ClampedArray(2)); // true
isTypedArray(new Int16Array(2)); // true
isTypedArray(new Uint16Array(2)); // true
isTypedArray(new Int32Array(2)); // true
isTypedArray(new Uint32Array(2)); // true
isTypedArray(new Float32Array(2)); // true
isTypedArray(new Float64Array(2)); // true
Negative Response
isTypedArray(['a', 'b', 'c']); // false
isTypedArray(1000n); // false
isTypedArray(true); // false
isTypedArray(new Date()); // false
isTypedArray(''); // false
isTypedArray(new Error('message')); // false
isTypedArray(3.14); // false
isTypedArray(() => 'function'); // false
isTypedArray(42); // false
isTypedArray(
new Map([
['a', 1],
['b', 2],
])
); // false
isTypedArray(null); // false
isTypedArray({ an: 'object' }); // false
isTypedArray(new Promise(() => {})); // false
isTypedArray(/[regex]+/gi); // false
isTypedArray(new Set([1, 2, 3])); // false
isTypedArray('a string'); // false
isTypedArray(Symbol()); // false
isTypedArray(undefined); // false