https://github.com/dan-online/cabinet
Cabinet, the easier way to manage files in Deno
https://github.com/dan-online/cabinet
cabinet deno denoland file filemanager files filesystem
Last synced: 7 months ago
JSON representation
Cabinet, the easier way to manage files in Deno
- Host: GitHub
- URL: https://github.com/dan-online/cabinet
- Owner: dan-online
- Created: 2020-06-16T19:49:48.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-03T08:40:48.000Z (almost 2 years ago)
- Last Synced: 2024-05-01T16:46:18.160Z (over 1 year ago)
- Topics: cabinet, deno, denoland, file, filemanager, files, filesystem
- Language: TypeScript
- Homepage: https://cabinet-benchmarks.netlify.app/
- Size: 15.6 MB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
> Cabinet, the easier way to manage files in Deno

# Cabinet
A module created for [Deno](https://deno.land) by [DanCodes](https://dancodes.online)



[](https://discord.gg/fdpcZAA)


[](https://doc.deno.land/https/deno.land/x/cabinet/mod.ts)
[](https://deno.land/x/cabinet)
[](https://nest.land/package/cabinet)
### Demo
This demo will open a file called testing.txt, write to it and then finally read it and display the contents in the console.
```bash
deno run --allow-write --allow-read https://deno.land/x/cabinet/demo.ts
```
### Todo
- Add file moving
- Add resolve function for stringified file
### Testing
```bash
deno test -A
```
### Use
```typescript
import {
Cabinet,
CabinetFile,
CabinetError,
} from "https://deno.land/x/cabinet/mod.ts";
const file = new Cabinet("./testing.txt");
file.write("The date is " + new Date());
file.write("The date is " + new Date(), () => console.log("finished!"));
file.writer.sync("This was written synchronously");
file.writer
.promise("This was written with a promise")
.then(() => console.log("finished!"));
file.writer.callback("This was written with a callback", () =>
console.log("finished!")
);
file.read();
file.read(() => console.log("finished!"));
file.reader.sync();
file.reader.promise().then((cFile: CabinetFile) => {
console.log("read " + cFile.size.mb + "mb in promise");
});
file.reader.callback((err?: CabinetError, cFile?: CabinetFile) => {
console.log("read " + cFile?.size.mb + "mb in callback");
});
```
## Format code
```bash
deno fmt **/*.ts
```
## Resources
- [Deno Website](https://deno.land)
- [Deno Style Guide](https://deno.land/std/style_guide.md)
- [Deno Gitter](https://gitter.im/denolife/Lobby)