MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / uniqueTitle

Function uniqueTitle

apps/desktop/src/main/vault.ts:2813–2825  ·  view source on GitHub ↗
(dir: string, baseTitle: string)

Source from the content-addressed store, hash-verified

2811}
2812
2813export async function uniqueTitle(dir: string, baseTitle: string): Promise<string> {
2814 let candidate = baseTitle
2815 let n = 1
2816 while (true) {
2817 try {
2818 await fs.access(path.join(dir, `${candidate}.md`))
2819 n += 1
2820 candidate = `${baseTitle} ${n}`
2821 } catch {
2822 return candidate
2823 }
2824 }
2825}
2826
2827async function uniqueFilename(dir: string, filename: string): Promise<string> {
2828 const ext = path.extname(filename)

Callers 7

createRecordPageFunction · 0.90
migrateOneLegacyDatabaseFunction · 0.70
createNoteFunction · 0.70
importExternalNoteFunction · 0.70
moveBetweenFoldersFunction · 0.70
moveNoteFunction · 0.70
duplicateNoteFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected