array
Array utilities.
Functions
Section titled “Functions”| Function | Description |
|---|---|
| filterInPlace | Filter an array in place. |
| snapshot | Copies an iterable into a new array, so it can be safely iterated while the original is modified. Use this whenever the loop body (or an awaited call inside it) adds to or removes from the collection being iterated — releasing locks, cancelling timers, settling pending operations. Iterating the live collection in those cases silently skips entries. Prefer this over an inline [...collection]: it says why the copy exists, and it keeps the call site clear of unicorn/no-useless-spread, which cannot tell a defensive copy from a redundant one. The result is readonly: it exists to be iterated, not worked on. Mutating it would change a throwaway copy and leave the original untouched, which is never what the caller wants. |
| unique | Remove duplicates from an array. |
| uniqueInPlace | Remove duplicates from an array in place. |