UNPKG

654 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.u8aEmpty = void 0;
4/**
5 * @name u8aEmpty
6 * @summary Tests for a `Uint8Array` for emptyness
7 * @description
8 * Checks to see if the input `Uint8Array` has zero length or contains all 0 values.
9 */
10function u8aEmpty(value) {
11 const len = value.length | 0;
12 // on smaller sizes, the byte-by-byte compare is faster than allocating
13 // another object for DataView (on very large arrays the DataView is faster)
14 for (let i = 0; i < len; i++) {
15 if (value[i] | 0) {
16 return false;
17 }
18 }
19 return true;
20}
21exports.u8aEmpty = u8aEmpty;