import Collection from '../Support/Collection'; import type Model from './Model'; import type { MaybeArray } from '../Support/type'; import type { RawAttributes, SimpleAttributeKeys } from './Concerns/HasAttributes'; export default class ModelCollection extends Collection { constructor(models?: MaybeArray); /** * Throw error if not every item is a Model. * * @param {any[]=} iterable * * @protected */ protected _throwIfNotModels(iterable?: any): void; /** * Determine if the given array is a Model array. * * @param {any} array * * @return {boolean} * * @protected */ protected static _isModelArray(array: any): array is M[]; /** * Check whether the given argument is (probably) model or not. * * @param {any} arg * * @return {boolean} * * @protected */ protected static _isModel(arg: any): arg is M; /** * Accepts ModelCollection, array of models, numbers and strings * in array format. All other values are discarded. * Returns a collection of ids in a string format. * * @param {any} values * * @return {string[]} * * @protected */ protected _getArgumentKeys(values: any): Collection; /** * Get the primary keys of the models. * * @return {Collection} */ modelKeys(): Collection>; /** * Find the Model(s) based on the given key(s). * * @param {string|number|string[]|number[]} key * @param {any} defaultVal * * @return {Model|ModelCollection|undefined|any} */ findByKey(key: ReturnType, defaultVal?: T): T | undefined; findByKey(key: (ReturnType)[], defaultVal?: ModelCollection): ModelCollection | undefined; /** * De-duplicate the collection. * Optionally find duplicates by key or method on model. * If key is undefined on the model, fall back to model check. * * @param {string|undefined} key * * @return {this} */ unique(key?: string | ((model: T) => any)): this; /** * Assert whether there are duplicates in the collection. * * @param {string|function|undefined} key * * @return {boolean} */ hasDuplicates(key?: SimpleAttributeKeys | ((model: T) => U)): boolean; /** * Only keep one instance of duplicated values in the collection. * Optionally find duplicates by key, method name or passed in method. * If key is undefined on the model, fall back to model check. * * @param {string|function} key * * @return {this} */ duplicates(key?: SimpleAttributeKeys | ((model: T) => U)): this; /** * Return only the models that are not in * both the argument and in the collection. * * @param {Model|ModelCollection|Model[]} models * * @return {this} */ diff(models: MaybeArray): this; /** * Only return the models with ids from the arguments. * * @param {any} values * * @return {this} */ only(values: MaybeArray): this; /** * Return all models except models with ids from the arguments. * * @param {any} values * * @return {this} */ except(values: MaybeArray): this; /** * Asserts whether the given value * is an instance of ModelCollection. * * @param value * * @return {boolean} */ static isModelCollection(value: any): value is ModelCollection; /** * Return only models that are both in * the arguments and the collection. * * @param {Model|ModelCollection|Model[]} models * * @return {this} */ intersect(models: MaybeArray): this; /** * Remove all models that are same as the argument * based on the Model's 'is()' method. * * @param {Model} model * * @return {this} * * @see Model#is */ delete(model: T): this; /** * Join this and the argument without overlapping models. * * @param {ModelCollection|Model[]} iterable * * @return {this} */ union(iterable: ModelCollection | T[]): this; /** * Assert whether the given model is in the collection. * * @param {Model|number|string} model * * @return {boolean} */ includes(model: T): boolean; /** * The push override. * * @param {...Model} items */ push(...items: T[]): number; /** * The unshift override. * * @param {...Model} items */ unshift(...items: T[]): number; /** * @inheritDoc */ map(callback: (value: T, index: number, array: T[]) => U, thisArg?: any): [U] extends [Model] ? ModelCollection : Collection; /** * @inheritDoc */ toJSON = RawAttributes>(): { elements: R[]; }; } //# sourceMappingURL=ModelCollection.d.ts.map