MCPcopy Index your code
hub / github.com/coder/mux / findMaxSequentialNumber

Function findMaxSequentialNumber

src/node/services/workspaceService.ts:720–735  ·  view source on GitHub ↗

* Find the highest sequential number among items that match `prefix trailingSuffix`. * Returns 0 when no items match.

(items: string[], prefix: string, trailingSuffix = "")

Source from the content-addressed store, hash-verified

718 * Returns 0 when no items match.
719 */
720function findMaxSequentialNumber(items: string[], prefix: string, trailingSuffix = ""): number {
721 let max = 0;
722 for (const item of items) {
723 if (!item.startsWith(prefix)) continue;
724 if (trailingSuffix && !item.endsWith(trailingSuffix)) continue;
725
726 const numberStr = trailingSuffix
727 ? item.slice(prefix.length, -trailingSuffix.length)
728 : item.slice(prefix.length);
729 if (!/^\d+$/.test(numberStr)) continue;
730
731 const n = Number(numberStr);
732 if (n > max) max = n;
733 }
734 return max;
735}
736
737function deriveForkFamilyBaseName(metadata: { name: string; forkFamilyBaseName?: string }): string {
738 if (metadata.forkFamilyBaseName) {

Callers 2

generateForkBranchNameFunction · 0.85
generateForkTitleFunction · 0.85

Calls 1

testMethod · 0.80

Tested by

no test coverage detected