UNPKG

pig-dam-core

Version:

Library that should be included in every Pig DAM project we build

57 lines 2.17 kB
/** * Date: 2019-07-09 * Time: 21:45 * @license MIT (see project's LICENSE file) */ import { compareAny } from "../../compare"; import { FailurePolicy } from "../../types"; import { ArrayInsertLocation, ArraySearchCriteria } from "../../types/mutation"; /** * Adds element. * @param array - may be null provided that this is an "dateAdd" operation * @param element - element to be inserted * @param location - optional location information * @throws {Error} */ export declare function add<T>(array: T[], element: T, location?: ArrayInsertLocation<T>): T[]; /** * Concatenates <param>array</param> and <param>elements</param> * @param array - may be null provided that there is no <param>index</param> * @param elements - elements be added or inserted * @param location - optional location information * @throws {Error} */ export declare function concat<T>(array: T[], elements: T[], location?: ArrayInsertLocation<T>): T[]; /** * Performs omit on each element in the specified array */ export declare function omit(array: object[], path: string): object[]; /** * Performs pick on each element in the specified array */ export declare function pick(array: object[], path: string): object[]; /** * @param array - array from which to remove element * @param criteria - criteria by which we find an index * @param onFail - whether to throw or not throw errors if not found */ export declare function remove<T>(array: T[], criteria: ArraySearchCriteria<T>, onFail?: FailurePolicy): T[]; /** * @param array - array from which to remove element * @param newElement - element to replace found searched for element * @param criteria - criteria by which we find an index * @throws {Error} if existing element cannot be found */ export declare function replace<T>(array: T[], newElement: T, criteria: ArraySearchCriteria<T>): T[]; /** * sorts array of objects by property key */ export declare function sort(array: { [key: string]: any; }[], property: string, { comparer, reverse }?: { comparer?: typeof compareAny | undefined; reverse?: boolean | undefined; }): { [key: string]: any; }[] | undefined; //# sourceMappingURL=array.d.ts.map