UNPKG

577 BJavaScriptView Raw
1/**
2 * @name isU8a
3 * @summary Tests for a `Uint8Array` object instance.
4 * @description
5 * Checks to see if the input object is an instance of `Uint8Array`.
6 * @example
7 * <BR>
8 *
9 * ```javascript
10 * import { isUint8Array } from '@polkadot/util';
11 *
12 * console.log('isU8a', isU8a([])); // => false
13 * ```
14 */
15export function isU8a(value) {
16 // here we defer the instanceof check which is actually slightly
17 // slower than just checking the constrctor (direct instances)
18 return (((value && value.constructor) === Uint8Array) ||
19 value instanceof Uint8Array);
20}
\No newline at end of file