import { Entity } from './entity'; import { EntityCallbackFn } from './entity-callback-fn'; import { EntityCollectionLike } from './entity-collection-like'; import { entityCollectionSymbol } from './entity-collection-symbol'; import { EntityFilterFn } from './entity-filter-fn'; import { EntityMapFn } from './entity-map-fn'; import { EntitySortFn } from './entity-sort-fn'; import { Nullable } from './nullable'; /** * Entity collection encapsulates array of entities and provides additional helper methods * to manipulate this array. * * @type {EntityCollection} */ export declare class EntityCollection { /** * Underlying array of entities. * * @type {Array} */ protected readonly entities: Array; /** * Constructor. * * @param {EntityCollectionLike} entityCollectionLike Entity collection like. */ constructor(entityCollectionLike?: EntityCollectionLike); /** * Gets iterator for a collection. * * @returns {Iterator} Iterator over entities. */ [Symbol.iterator](): Iterator; /** * Gets underlying array of entities. Besides this symbol is used to identify entity collection between modules. * * @returns {ReadonlyArray} Underlying array of entities. */ [entityCollectionSymbol](): ReadonlyArray; /** * Gets length of the collection. This is a number one higher than the highest * index in the collection. * * @returns {number} Length of the collection. */ get length(): number; /** * Removes the first entity from a collection and returns it. If the collection is empty, null is * returned and the collection is not modified. * * @returns {Nullable} First entity removed from a collection or null if collection is empty. */ shift(): Nullable; /** * Removes the last entity from a collection and returns it. If the collection is empty, null is * returned and the collection is not modified. * * @returns {Nullable} Last entity removed from a collection or null if collection is empty. */ pop(): Nullable; /** * Appends new entities to the end of a collection, and returns the new length of the collection. * * @param {Array} entities Array of entities to append. * * @returns {number} New length of entity collection. */ push(...entities: Array): number; /** * Inserts new entities at the start of a collection, and returns the new length of the collection. * * @param {Array} entities Array of entities to append. * * @returns {number} New length of entity collection. */ unshift(...entities: Array): number; /** * Combines two or more entity collections. * * @param {Array>} entityCollections Entity collections. * * @returns {EntityCollection} New entity collection without modifying any existing one. */ concat(...entityCollections: Array>): EntityCollection; concat(...entityArrays: Array>): EntityCollection; /** * Returns a copy of a section of a collection. For both start and end, a negative index can be used * to indicate an offset from the end of the collection. For example, -2 refers to the second to last element of the collection. * * @param {number} start The beginning inclusive index of the specified portion of the array. If start is undefined, then the slice begins at index 0. * @param {number} end The end exclusive index of the specified portion of the array. If end is undefined, then the slice extends to the end of the array. * * @returns {EntityCollection} Entity collection representing a slice. */ slice(start?: number, end?: number): EntityCollection; /** * Reverses the entities in a collection in place. This method mutates the collection and * returns a reference to the same collection. * * @returns {EntityCollection} Current instance of entity collection. */ reverse(): EntityCollection; /** * Sorts a collection in place. This method mutates the collection and returns a reference to the same collection. * * @param {EntitySortFn} entitySortFn Function used to determine the order of the entities. * * @returns {EntityCollection} Sorted entity collection. */ sort(entitySortFn: EntitySortFn): EntityCollection; /** * Returns the index of the first occurrence of an entity in a collection, or -1 if it is not present. * * @param entity The entity to locate in the collection. * @param fromIndex The collection index at which to begin the search. If fromIndex is omitted, the search starts at index 0. * * @returns {number} Entity index in the collection or -1 if it is not present. */ indexOf(entity: TEntity, fromIndex?: number): number; /** * Determines whether all the entities of a collection satisfy the specified filter function. * * @param {EntityFilterFn} entityFilterFn Entity filter function. * * @returns {boolean} True when all the entities of a collection satisfy the specified filter function. False otherwise. */ every(entityFilterFn: EntityFilterFn): boolean; /** * Determines whether the specified filter function returns true for any entity of a collection. * * @param {EntityFilterFn} entityFilterFn Entity filter function. * * @returns {boolean} True when any entity of a collection satisfy the specified filter function. False otherwise. */ some(entityFilterFn: EntityFilterFn): boolean; /** * Performs the specified action for each entity in a collection. * * @param {EntityCallbackFn} entityCallbackFn Entity callback function. * * @returns {void} Nothing. */ forEach(entityCallbackFn: EntityCallbackFn): void; /** * Calls a defined map function on each entity of a collection, and returns an array that contains the results. * * @param {EntityMapFn} entityMapFn Entity map function. * * @returns {Array} Array of map results. */ map(entityMapFn: EntityMapFn): Array; /** * Returns the entity collection with entities that meet the condition specified in a filter function. * * @param {EntityFilterFn} entityFilterFn Entity filter function. * * @returns {EntityCollection} Filtered entity collection. */ filter(entityFilterFn: EntityFilterFn): EntityCollection; /** * Checks if collection is empty. * * @returns {boolean} True when collection is empty. False otherwise. */ isEmpty(): boolean; /** * Gets first entity mathing the filter function or null if it is not found. If filter function is undefined then tries to get the * first entity in the collection. * * @param {EntityFilterFn} entityFilterFn Entity filter function. * * @returns {Nullable} First entity matching the filter function or null if it is not found. */ first(entityFilterFn?: EntityFilterFn): Nullable; /** * Gets last entity mathing the filter function or null if it is not found. If filter function is undefined then tries to get the * last entity in the collection. * * @param {EntityFilterFn} entityFilterFn Entity filter function. * * @returns {Nullable} Last entity matching the filter function or null if it is not found. */ last(entityFilterFn?: EntityFilterFn): Nullable; /** * Finds entity matching the filter function. * * @param {EntityFilterFn} entityFilterFn Entity filter function. * * @returns {Nullable} Entity or null if it is not found. */ find(entityFilterFn: EntityFilterFn): Nullable; /** * Clears the entity collection. This method mutates entity collection and returns * current instance. * * @returns {EntityCollection} Cleared instance of entity collection. */ clear(): EntityCollection; /** * Tries to remove provided entity from a collection. * * @param {TEntity} entity Entity to remove. * * @returns {boolean} True if entity is removed. False otherwise. */ remove(entity: TEntity): boolean; /** * Tries to get entity at provided index. * * @param {number} index Index of entity. * * @returns {Nullable} Entity or null if it is not present. */ at(index: number): Nullable; /** * Converts entity collection to array. * * @returns {ReadonlyArray} Array of entities. */ toArray(): ReadonlyArray; /** * Checks if collection contains entity. * * @param {TEntity} entity Target entity. * * @returns {boolean} True if collection contains entity. False otherwise. */ contains(entity: TEntity): boolean; } //# sourceMappingURL=entity-collection.d.ts.map