char/avril
(wip) why'd you have to go and make things so complicaaaaated?
git clone https://git.t4t.associates/char/avril
83ff6f3
main
1import { 2format , 3fromFileUrl , 4join , 5parse , 6posix , 7relative , 8resolve , 9sep , 10toFileUrl , 11win32 , 12type ParsedPath , 13type Path , 14type PathObject , 15} from "avril:path" ; 16import { 17delimiter as posixDelimiter , 18format as posixFormat , 19join as posixJoin , 20parse as posixParse , 21sep as posixSep , 22toFileUrl as posixToFileUrl , 23} from "avril:path/posix" ; 24import { 25delimiter as win32Delimiter , 26join as win32Join , 27sep as win32Sep , 28} from "avril:path/win32" ; 29 30const parsed :ParsedPath = parse ( "/a/b/c.txt" ); 31const dir :string = parsed . dir ; 32const formatted :string = format ({ dir :"/a/b" , base :"c.txt" }); 33const flavor :Path = posix ; 34const joined :string = join ( "a" , "b" ); 35const resolved :string = resolve ( "/a" , "b" ); 36const related :string = relative ( "/a" , "/a/b" ); 37const obj :PathObject = { root :"/" , base :"x" }; 38 39// The flavors pin their separators as literals. 40const posixSeparator :"/" = posixSep ; 41const posixDelim :":" = posixDelimiter ; 42const win32Separator :"\\" = win32Sep ; 43const win32Delim :";" = win32Delimiter ; 44// @ts-expect-error posix sep is a forward slash. 45const wrongPosixSep :"/" = win32Sep ; 46// @ts-expect-error win32 sep is a backslash. 47const wrongWin32Sep :"\\" = posixSep ; 48// @ts-expect-error posix delimiter is a colon. 49const wrongPosixDelim :":" = win32Delimiter ; 50// The native flavor varies by host, so its separators stay `string`: this 51// passes only for plain `string` and fails for `"/"` and `"\\"` alike. 52const arbitrary :typeof sep = "any string" ; 53const nativePosix :Path = posix ; 54const nativeWin32 :Path = win32 ; 55 56const url = toFileUrl ( "/a/b" ); 57const back :string = fromFileUrl ( url ); 58const posixUrl = posixToFileUrl ( "/a/b" ); 59const posixJoined :string = posixJoin ( "a" , "b" ); 60const win32Joined :string = win32Join ( "a" , "b" ); 61const posixFormatted :string = posixFormat ({ dir :"a" , base :"b" }); 62const posixParsed :ParsedPath = posixParse ( "a/b" ); 63void parsed ; 64void formatted ; 65void flavor ; 66void joined ; 67void resolved ; 68void related ; 69void obj ; 70void posixSeparator ; 71void posixDelim ; 72void win32Separator ; 73void win32Delim ; 74void wrongPosixSep ; 75void wrongWin32Sep ; 76void wrongPosixDelim ; 77void arbitrary ; 78void nativePosix ; 79void nativeWin32 ; 80void url ; 81void back ; 82void posixUrl ; 83void posixJoined ; 84void win32Joined ; 85void posixFormatted ; 86void posixParsed ;