UNPKG

@freeword/meta

Version:

Meta package for Freeword: exports all core types, constants, and utilities from the src/ directory.

22 lines 1.03 kB
import _ /**/ from 'lodash'; import { Z } from "../validation/ZodInternal.js"; import { throwable } from "./OutcomeUtils.js"; export const arrNZT = Z.array(Z.any()).nonempty().describe('Non-empty array'); export const arrNZROT = arrNZT.readonly().describe('Non-empty readonly array'); export function arrNZ(arr) { return arrNZT.cast(arr); } export function cheatNZ(arr) { return arr; } export function nonemptyArrToFill() { return []; } export function isArrRO(arr) { return _.isArray(arr); } export function isArrNZRO(arr) { return _.isArray(arr) && arr.length > 0; } export function arrNZRO(arr) { return arrNZROT.cast(arr); } export function cheatNZRO(arr) { return arr; } // export function arrRO(arr) { return arr; } export function appendMutatingly(target, ...rest) { if (!_.isFunction(target?.splice)) { throw throwable('Need an array to append to', 'mistyped', { val: target, rest }); } target.splice(target.length, 0, ...rest.flat()); return target; } //# sourceMappingURL=CollectionUtils.js.map