delimitedPath
Custom delimiter path helpers (e.g. -- visual groups). Does not handle filesystem / \.
split:
{"path":["chat","call"],"leaf":"voice-line"}parent:
chat--calllabel:
voice-linebelongsToPrefix:
trueSignatures
typescript
function splitDelimitedPath(value: string, sep: string): DelimitedPathParts
function joinDelimitedPath(segments: readonly string[], sep: string): string
function delimitedPathParent(path: string, sep: string): string | null
function delimitedPathDisplayLabel(path: string, sep: string): string
function belongsToDelimitedPrefix(value: string, prefix: string, sep: string): booleanUsage
typescript
import {
splitDelimitedPath,
joinDelimitedPath,
delimitedPathParent,
belongsToDelimitedPrefix,
} from '@zengchaowu/shared/functions/path/delimitedPath'
const sep = '--'
splitDelimitedPath('chat--call--voice-line', sep)
// { path: ['chat', 'call'], leaf: 'voice-line' }
joinDelimitedPath(['chat', 'call'], sep)
// 'chat--call'
delimitedPathParent('chat--call', sep)
// 'chat'
belongsToDelimitedPrefix('chat--call--voice-line', 'chat--call', sep)
// truevs pathLastSegment
- delimitedPath: explicit
sepfor business group paths - pathLastSegment / pathBasename: filesystem style with
/and\