import { b as ID, n as ArrayPredicate, t as ArrayElementResolvable, x as nil } from "./array-C6YBhEyW.js"; import { Resolvable } from "jtilz"; //#region src/fp/array.d.ts /** * Appends elements onto the end of the array. */ declare function arrayPush(...values: T[]): (a: T[] | nil) => T[]; /** * Pops an element off the end of the array. */ declare function arrayPop(howMany?: number): (a: T[] | nil) => T[]; /** * Insert one or more elements into an array at the given position. */ declare function arrayInsert(index: number, ...values: T[]): (a: T[] | nil) => T[]; /** * Insert numbers into a sorted array, using binary search to find their position. * * @param values Values to insert. These needn't be sorted; each one will be searched for individually. */ declare function arrayInsertSorted(...values: number[]): (a: number[] | nil) => number[]; /** * Prepends elements onto the end of the array. */ declare function arrayUnshift(...values: T[]): (a: T[] | nil) => T[]; /** * Deletes elements from an array by index. */ declare function arrayDeleteIndex(...indices: number[]): (a: T[] | nil) => T[]; /** * Deletes up to one element from an array, searching by value. * @deprecated */ declare function arrayDeleteOneValue(value: T, strict: boolean): (a: T[] | nil) => T[]; /** * Deletes up to one element from an array, searching by value. */ declare function arrayDeleteValue(value: T, strict: boolean, limit?: number): (a: T[] | nil) => T[]; /** * Filters the array to elements that pass the predicate. * If limit is provided, returned array will be at most that length. */ declare function arraySelect(predicate: (v: T, i: number) => boolean, limit?: number): (a: T[] | nil) => T[]; /** * Removes elements for which the predicate returns true. * If limit is provided, at most that many elements will be deleted. i.e. new length will be >= array.length - limit. */ declare function arrayReject(predicate: (v: T, i: number) => boolean, limit?: number): (a: T[] | nil) => T[]; /** * Replaces `count` elements starting at the given `index` with `replaceWith` elements. */ declare function arraySplice(index: number, count?: number, ...replaceWith: T[]): (a: T[] | nil) => T[]; declare function arrayFindAndReplace(predicate: ArrayPredicate, replaceWith: ArrayElementResolvable): (a: T[] | nil) => T[]; //#endregion //#region src/fp/map.d.ts /** * Set a key in a Map. */ declare function mapSet(key: K, value: Resolvable): (map: Map | nil) => Map; /** * Update an existing value in a map. * Returns the map as-is if the key does not exist. */ declare function mapUpdate(key: K, value: Resolvable): (map: Map) => Map; /** * Merge multiple entries into a map. */ declare function mergeMap(values: Resolvable]>, [Map]>): (map: Map) => Map; /** * Delete one or more keys from a map. */ declare function mapDelete(...keys: K[]): (map: Map | nil) => Map; //#endregion //#region src/fp/number.d.ts /** * Adds a value to a number. Defaults to 0 if undefined. */ declare function add(value: number): (prev: number | nil) => number; /** * Subtracts a value from a number. Defaults to 0 if undefined. */ declare function sub(value: number): (prev: number | nil) => number; /** * Multiplies a number by a value. Defaults to 0 if undefined. */ declare function mult(value: number): (prev: number | nil) => number; /** * Divides a number by a value. Defaults to 0 if undefined. */ declare function div(value: number): (prev: number | nil) => number; //#endregion //#region src/fp/object.d.ts type KeysOfUnion = T extends T ? keyof T : never; type PatchValue = T extends T ? (K extends keyof T ? T[K] : never) : never; type Widen = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T extends bigint ? bigint : T extends symbol ? symbol : T; type ResolvedPatchValue = T extends ((...args: any[]) => infer R) ? R : T; type MergeTarget = { [K in KeysOfUnion]: Widen>> }; type InvalidPatchKeys = { [K in KeysOfUnion]: K extends keyof TObj ? PatchValue extends TObj[K] ? never : K : K }[KeysOfUnion]; type PatchTarget = [InvalidPatchKeys] extends [never] ? TObj : never; type MergeObject = { [K in keyof T]?: T[K] | ((value: T[K], key: K) => T[K] | Widen) }; type ValueMergeObject = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? never : T[K] }; type ValueMergeObjects> = { [K in keyof T]: T[K] extends object ? ValueMergeObject : T[K] }; type IsAny = 0 extends 1 & T ? true : false; /** * Merge one or more objects into a target object, similar to * [`Object.assign`]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign}, but each value can be a function that takes the previous value for that key and returns a new one. * * The target object *should* be the full object (with all keys defined), and the objects to be merged may be partial. * If the target and objects to be merged do not sum up to the full object, then the return type will be invalid. */ declare function shallowMerge(...objects: Array>>): (obj: T) => T; declare function shallowMerge>(...objects: IsAny extends true ? never : ValueMergeObjects): (obj: PatchTarget) => TObj; /** * Exactly the same as {@link shallowMerge} but the types are relaxed to accept `undefined` and `null`. You may want * to use this version when the target object is potentially undefined but you know that the to-be merged objects will * result in a full object. This version is harder for TypeScript to infer the proper type, so you may need to * explicitly pass ``. */ declare const relaxedMerge: { >(...objects: T): >>(obj: TObj | nil) => TObj & {}; (...objects: Array | nil>): (obj: T | nil) => T & {}; }; /** * Create an immutable updater that replaces one object property with a resolved value. * * @example * ```ts * type Size = { * width: number * height: number * } * * const growWidth = objSet('width', (width) => width + 64) * const next = growWidth({ width: 512, height: 768 }) * // { width: 576, height: 768 } * ``` * * @param key - The property key to replace. * @param value - The next value, or a function that receives the previous value and returns the next value. * @returns A function that copies the input object and replaces the selected property. */ declare function objSet(key: keyof T, value: Resolvable): (obj: T) => T; //#endregion //#region src/fp/set.d.ts /** * Add or remove a value from a set. */ declare function setCheck(value: T, add: boolean): ID>; /** * Adds one or more values to a set. */ declare function setAdd(...values: T[]): ID>; /** * Removes one or more values from a set. */ declare function setRemove(...values: T[]): ID>; //#endregion export { add, arrayDeleteIndex, arrayDeleteOneValue, arrayDeleteValue, arrayFindAndReplace, arrayInsert, arrayInsertSorted, arrayPop, arrayPush, arrayReject, arraySelect, arraySplice, arrayUnshift, div, mapDelete, mapSet, mapUpdate, mergeMap, mult, objSet, relaxedMerge, setAdd, setCheck, setRemove, shallowMerge, sub };