@mocanvas/store · function

getIndices

declare function getIndices(n: number, start?: IndexKey): IndexKey[]

start, followed by n freshly generated keys above it.

**n counts the NEW keys, so the array is n + 1 long.** start is an index you already have and is echoed back verbatim — unjittered, because it is an input rather than something this generated:

``ts getIndices(3, "a1") // ["a1", "a2…", "a3…", "a4…"] getIndices(0) // ["a1"] — a start and nothing after it ``

This used to return n keys of which start was the first, so getIndices(1) generated nothing at all, and the default start was a0. Both were wrong against the helper of this name that migrating code is written against, in the quiet way: same name, same argument shape, an answer one bucket off and one element short. COMPAT.md's rule for exactly this case is that an undocumented helper behaving almost-right is worse than one that is absent and reported by the compiler.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.