MCPcopy Index your code
hub / github.com/massCodeIO/massCode / getUniqueNoteName

Function getUniqueNoteName

src/main/import/notes/persist.ts:55–73  ·  view source on GitHub ↗
(
  notes: ReturnType<ReturnType<typeof useNotesStorage>['notes']['getNotes']>,
  name: string,
)

Source from the content-addressed store, hash-verified

53}
54
55function getUniqueNoteName(
56 notes: ReturnType<ReturnType<typeof useNotesStorage>['notes']['getNotes']>,
57 name: string,
58): string {
59 const names = new Set(notes.map(note => note.name.toLowerCase()))
60
61 if (!names.has(name.toLowerCase())) {
62 return name
63 }
64
65 for (let suffix = 1; suffix <= 10_000; suffix += 1) {
66 const candidate = `${name} ${suffix}`
67 if (!names.has(candidate.toLowerCase())) {
68 return candidate
69 }
70 }
71
72 return `${name} ${Date.now()}`
73}
74
75function createImportRunFolder(parentId: number | null): {
76 id: number

Callers 1

createNoteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected