@mocanvas/editor · function

getIncrementedName

declare function getIncrementedName(name: string, others: Iterable<string>): string

A name that is not already taken: "Page" becomes "Page 1", then "Page 2", and "Page 2" itself becomes "Page 3".

Used wherever a duplicate has to be given a name a human would have chosen — duplicating a page, a frame, an exported file.

SEMANTICS-ASSUMED: a trailing integer on name is treated as a counter and continued rather than being kept and appended to, so duplicating "Page 2" twice gives "Page 3" and "Page 4" rather than "Page 2 1" and "Page 2 2". The docs pin neither; this is the behaviour every file manager has trained people to expect.

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.