(items: Array<T>, item: T, max = 0)
| 594 | * @returns A new array with `item` added. |
| 595 | */ |
| 596 | export function addToEnd<T>(items: Array<T>, item: T, max = 0): Array<T> { |
| 597 | const newItems = [...items, item] |
| 598 | return max && newItems.length > max ? newItems.slice(-max) : newItems |
| 599 | } |
| 600 | |
| 601 | /** |
| 602 | * Returns a new array with `item` added at the start. If that makes the array longer than `max`, |
no outgoing calls
no test coverage detected