import { Props } from "./Objects"; export interface ArrayMapEvents { onInit?: (data: T[]) => any; onCreated?: (index: number, key: any, value: T) => any; onUpdated?: (index: number, key: any, value: T, oldValue: T) => any; onDeleted?: (value: T[]) => any; } export interface ArrayMapGetKey { (item: T): string; } export interface ArrayMapProps = Props> { key?: string; keys?: string[]; data?: T[]; events?: ArrayMapEvents; newMap?: () => Props; getKey?: ArrayMapGetKey; } export interface ArrayMapGetItem { (item: T, index?: number): string; } export default class ArrayMap = Props> { static readonly defaultKey = "id"; private _data; private dataMap; private _alias; private _key; private _keys; private _events; private newMap; private _getKey; constructor(props?: ArrayMapProps); push(...items: (T | T[])[]): number; /** * Removes the last element from an array and returns it. */ pop(): T; /** * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ concat(...items: (ArrayMap | T[])[]): ArrayMap; /** * Adds all the elements of an array separated by the specified separator string. * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. * @param get */ join(separator: string, get?: (item: T, index?: number) => string): string; /** * Reverses the elements in an Array. */ reverse(): ArrayMap; /** * Removes the first element from an array and returns it. */ shift(): T; /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. * @param end The end of the specified portion of the array. */ slice(start?: number, end?: number): ArrayMap; /** * Sorts an array. * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: T, b: T) => number): ArrayMap | any; /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. * @param deleteCount The number of elements to remove. */ splice(start: number, deleteCount?: number): ArrayMap | undefined; /** * Inserts new elements at the start of an array. * @param items Elements to insert at the start of the Array. */ unshift(...items: (T | T[])[]): number; first: T; last: T; private upsert; /** * Returns the index of the first occurrence of a value in an array. * @param searchElement The value to locate in the array. * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. */ indexOf(searchElement: T | string, fromIndex?: number): number; /** * Returns the index of the last occurrence of a specified value in an array. * @param searchElement The value to locate in the array. * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. */ lastIndexOf(searchElement: T | string, fromIndex?: number): number; readonly length: number; refresh(): void; set(key: number | string, value: T): boolean; setKey(key: string, item: T): T; get(key: number | string): T; removeByIndex(value: number): T | undefined; removeByKey(value: string): T; remove(value: number | string | T): T | undefined; key(value: T | number): string; getKey(item: T): string; readonly nameOfKey: string; data: T[]; onInit(data: T[]): void; onCreated(index: number, key: any, value: T): void; onUpdated(index: number, key: any, value: T, oldValue: T): void; onDeleted(value: T[]): void; clone(data?: T[]): ArrayMap; static removeByIndex>(map: ArrayMap, value: number): T | undefined; static remove>(map: ArrayMap, value: number | string | T): T | undefined; static setKey>(map: ArrayMap, key: string, item: T): T; static getKey>(map: ArrayMap, item: T): string; static assertKey>(map: ArrayMap, item: T | number): string; }