( items: Array<T>, item: T, max?: number, prepend?: boolean, )
| 599 | * @returns A new array with `item` added. |
| 600 | */ |
| 601 | export function addToArray<T>( |
| 602 | items: Array<T>, |
| 603 | item: T, |
| 604 | max?: number, |
| 605 | prepend?: boolean, |
| 606 | ): Array<T> { |
| 607 | const newItems = prepend ? [item, ...items] : [...items, item] |
| 608 | if (max && newItems.length > max) { |
| 609 | return prepend ? newItems.slice(0, max) : newItems.slice(-max) |
| 610 | } |
| 611 | return newItems |
| 612 | } |
| 613 | |
| 614 | /** |
| 615 | * Sentinel value that can be passed as a query's `queryFn` to conditionally disable the query (equivalent |
no outgoing calls
no test coverage detected