char/avril
(wip) why'd you have to go and make things so complicaaaaated?
git clone https://git.t4t.associates/char/avril
766372c
main
1import { 2copy , 3exists , 4makeTempDir , 5makeTempFile , 6mkdirs , 7move , 8readFile , 9readTextFile , 10writeFile , 11writeTextFile , 12type CopyOptions , 13type MakeTempOptions , 14type WriteFileOptions , 15} from "avril:fs" ; 16import { 17copy as copySync , 18exists as existsSync , 19makeTempDir as makeTempDirSync , 20makeTempFile as makeTempFileSync , 21mkdirs as mkdirsSync , 22move as moveSync , 23readFile as readFileSync , 24readTextFile as readTextFileSync , 25writeFile as writeFileSync , 26writeTextFile as writeTextFileSync , 27} from "avril:fs/sync" ; 28 29const data :Promise < Uint8Array > = readFile ( "data" ); 30const text :Promise < string > = readTextFile ( new URL ( "file:///data" )); 31const written :Promise < void > = writeFile ( "out" , new Uint8Array (), { create :true }); 32const writtenText :Promise < void > = writeTextFile ( "out" , "hi" , { mode :0o644 }); 33const made :Promise < void > = mkdirs ( "dir" , { mode :0o755 }); 34const dir :Promise < string > = makeTempDir ({ prefix :"a" }); 35const file :Promise < string > = makeTempFile ({ suffix :"b" }); 36const copied :Promise < void > = copy ( "a" , "b" , { dereference :true }); 37const moved :Promise < void > = move ( "a" , "b" ); 38const present :Promise < boolean > = exists ( "a" ); 39const options :CopyOptions = { dereference :false }; 40const tempOptions :MakeTempOptions = { dir :"tmp" , prefix :"a" , suffix :"b" }; 41const writeOptions :WriteFileOptions = { append :true , create :true , createNew :false , mode :0o600 }; 42// @ts-expect-error writeFile requires a Uint8Array. 43writeFile ( "out" , "nope" ); 44// @ts-expect-error paths are strings or URLs. 45readFile ( 42 ); 46 47const syncData :Uint8Array = readFileSync ( "data" ); 48const syncText :string = readTextFileSync ( "data" ); 49const syncWritten :void = writeFileSync ( "out" , new Uint8Array ()); 50const syncWrittenText :void = writeTextFileSync ( "out" , "hi" ); 51const syncMade :void = mkdirsSync ( "dir" ); 52const syncDir :string = makeTempDirSync (); 53const syncFile :string = makeTempFileSync (); 54const syncCopied :void = copySync ( "a" , "b" ); 55const syncMoved :void = moveSync ( "a" , "b" ); 56const syncPresent :boolean = existsSync ( "a" ); 57// @ts-expect-error sync paths are strings or URLs. 58readFileSync ( 42 ); 59void data ; 60void text ; 61void written ; 62void writtenText ; 63void made ; 64void dir ; 65void file ; 66void copied ; 67void moved ; 68void present ; 69void options ; 70void tempOptions ; 71void writeOptions ; 72void syncData ; 73void syncText ; 74void syncWritten ; 75void syncWrittenText ; 76void syncMade ; 77void syncDir ; 78void syncFile ; 79void syncCopied ; 80void syncMoved ; 81void syncPresent ;