UNPKG

@hyperlane-xyz/utils

Version:

General utilities and types for the Hyperlane network

26 lines 758 B
import { sortBy } from 'lodash-es'; import { randomInt } from './math.js'; export function chunk(str, size) { const R = []; for (let i = 0; i < str.length; i += size) { R.push(str.slice(i, i + size)); } return R; } export function exclude(item, list) { return list.filter((i) => i !== item); } export function randomElement(list) { return list[randomInt(list.length)]; } export function sortArrayByKey(array, sortKey) { return sortBy(array, [(item) => item[sortKey]]); } // Validates that 2 arrays are equal in both ordering and elements export function arrayEqual(a, b) { if (a.length !== b.length) { return false; } return a.every((item, idx) => item === b[idx]); } //# sourceMappingURL=arrays.js.map