UNPKG

695 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.isU8a = void 0;
4/**
5 * @name isU8a
6 * @summary Tests for a `Uint8Array` object instance.
7 * @description
8 * Checks to see if the input object is an instance of `Uint8Array`.
9 * @example
10 * <BR>
11 *
12 * ```javascript
13 * import { isUint8Array } from '@polkadot/util';
14 *
15 * console.log('isU8a', isU8a([])); // => false
16 * ```
17 */
18function isU8a(value) {
19 // here we defer the instanceof check which is actually slightly
20 // slower than just checking the constrctor (direct instances)
21 return (((value && value.constructor) === Uint8Array) ||
22 value instanceof Uint8Array);
23}
24exports.isU8a = isU8a;