Optional
models: MaybeArray<T>Protected
_allProtected
Determine whether all the values in this are objects.
Protected
_getProtected
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.
Protected
_newProtected
Workaround to return a new current class.
Optional
items: MaybeArray<T>Private
_setPrivate
Set the values in context.
Protected
_throwChunk the collection into chunks of the given size.
Chunk the collection by the specified key.
Array.prototype.concat
Rest
...items: ConcatArray<T>[]Array.prototype.copyWithin
Optional
end: numberRemove all models that are same as the argument based on the Model's 'is()' method.
Model#is
Return only the models that are not in both the argument and in the collection.
Print the collection values to the console.
Optional
message: stringOnly 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.
Optional
key: SimpleAttributeKeys<T> | ((model: T) => U)Array.prototype.every
Optional
thisArg: anyOptional
thisArg: anyReturn all models except models with ids from the arguments.
Array.prototype.fill
Optional
start: numberOptional
end: numberArray.prototype.filter
Optional
thisArg: anyArray.prototype.find
Optional
thisArg: anyFind the Model(s) based on the given key(s).
Optional
defaultVal: TOptional
defaultVal: ModelCollection<T>Array.prototype.findIndex
Optional
thisArg: anyReturn the first element in the collection, if callback given the first element that passes the truth test. Otherwise, undefined.
Optional
callback: ((item: T, index: number) => boolean)Array.prototype.flat
Array.prototype.flatMap
Optional
thisArg: ThisOptional
thisArg: any[]Assert whether there are duplicates in the collection.
Optional
key: SimpleAttributeKeys<T> | ((model: T) => U)Return only models that are both in the arguments and the collection.
Return the last element in the collection, if callback given the last element that passes the truth test. Otherwise, undefined.
Optional
callback: ((item: T, index: number) => boolean)Array.prototype.map
Optional
thisArg: anyGet the primary keys of the models.
Only keep every nth element in the collection.
Only return the models with ids from the arguments.
Order the collection by given configurations(s)
Rest
...additional: T extends Record<PropertyKey, any> ? Order<T>[] : neverPad collection to the specified length with a value. Negative length will pad the beginning of the collection.
Optional
value: T | (() => T)Sort the items into a collection of their own based on weather they pass the given truthfulness test.
Pass the collection to a given function.
Get a collection with the values of a given key.
Return a random element(s) from the collection.
Array.prototype.reduce
Optional
initialValue: TArray.prototype.reduceRight
Optional
initialValue: TArray.prototype.reverse
Randomise the order of elements in the collection using the algorithm.
Skip items in the collection until the specified count from the start or end based on the argument.
Skip items in the collection until the given closure with the current item resolves to false.
Skip items in the collection while the given closure with the current item resolves to true.
Array.prototype.slice
Optional
start: numberOptional
end: numberArray.prototype.some
Optional
thisArg: anyArray.prototype.sort
Optional
compareFn: ((a: T, b: T) => number)Array.prototype.splice
Rest
...items: T[]Return the specified number of elements from the collection's start or end on negative argument.
Take items in the collection until the given closure with the current item resolves to false.
Take items in the collection while the given closure with the current item resolves to true.
Pass a clone of the collection to a given function.
Join this and the argument without overlapping models.
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.
Optional
key: string | ((model: T) => any)Call a callback on the collection unless the first argument is Boolean(true) or a closure called with the collection resolving to a value converted to boolean.
Call a callback on the collection when the first argument is Boolean(true) or a closure called with the collection resolving to a value converted to boolean.
Call the given callback with the collection if the collection is empty.
Call the given callback with the collection if the collection is not empty.
Filter out null and undefined values.
Static
Protected
_isProtected
Check whether the given argument is (probably) model or not.
Static
Protected
_isProtected
Determine if the given array is a Model array.
Static
isAsserts whether the given value is an instance of Collection.
Static
isAsserts whether the given value is an instance of ModelCollection.
Static
timesCreate a new collection from the evaluated callback or value the given number of times.
Generated using TypeDoc
The length of the collection.