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

Function duplicateFolderKeyMap

packages/app-core/src/lib/vault-layout.ts:738–757  ·  view source on GitHub ↗
(
  map: Record<string, T>,
  folder: NoteFolder,
  sourceSubpath: string,
  targetSubpath: string
)

Source from the content-addressed store, hash-verified

736}
737
738function duplicateFolderKeyMap<T>(
739 map: Record<string, T>,
740 folder: NoteFolder,
741 sourceSubpath: string,
742 targetSubpath: string
743): Record<string, T> {
744 const next: Record<string, T> = { ...map }
745 const exactKey = folderIconKey(folder, sourceSubpath)
746 const prefix = `${exactKey}/`
747 for (const [key, value] of Object.entries(map)) {
748 if (key === exactKey) {
749 next[folderIconKey(folder, targetSubpath)] = value
750 continue
751 }
752 if (key.startsWith(prefix)) {
753 next[folderIconKey(folder, targetSubpath) + key.slice(exactKey.length)] = value
754 }
755 }
756 return next
757}
758
759export function rewriteFolderColorsForRename(
760 folderColors: Record<string, FolderColorId>,

Callers 1

duplicateFolderColorsFunction · 0.85

Calls 1

folderIconKeyFunction · 0.70

Tested by

no test coverage detected