MCPcopy Create free account
hub / github.com/Effect-TS/effect / dirname

Function dirname

packages/effect/src/Path.ts:613–635  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

611 },
612
613 dirname(path) {
614 if (path.length === 0) return "."
615 let code = path.charCodeAt(0)
616 const hasRoot = code === 47 /*/*/
617 let end = -1
618 let matchedSlash = true
619 for (let i = path.length - 1; i >= 1; --i) {
620 code = path.charCodeAt(i)
621 if (code === 47 /*/*/) {
622 if (!matchedSlash) {
623 end = i
624 break
625 }
626 } else {
627 // We saw the first non-path separator
628 matchedSlash = false
629 }
630 }
631
632 if (end === -1) return hasRoot ? "/" : "."
633 if (hasRoot && end === 1) return "//"
634 return path.slice(0, end)
635 },
636
637 basename(path, ext) {
638 let start = 0

Callers 5

run.mjsFile · 0.85
writeJsonFunction · 0.85
compare.mjsFile · 0.85
writeJsonFunction · 0.85
writeSourceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected