Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: 4 months ago
JSON representation

Cabinet, the easier way to manage files in Deno

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)

![.github/workflows/deno-win.yml](https://github.com/dan-online/cabinet/workflows/.github/workflows/deno-win.yml/badge.svg)
![.github/workflows/deno-linux.yml](https://github.com/dan-online/cabinet/workflows/.github/workflows/deno-linux.yml/badge.svg)
![.github/workflows/deno-mac.yml](https://github.com/dan-online/cabinet/workflows/.github/workflows/deno-mac.yml/badge.svg)
[![DanCodes Discord](https://img.shields.io/discord/478586684666150934?color=%237289DA&label=discord%20support&logo=discord&logoColor=%23fff)](https://discord.gg/fdpcZAA)
![GitHub repo size](https://img.shields.io/github/repo-size/dan-online/cabinet)
![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/dan-online/cabinet)
[![Docs](https://img.shields.io/badge/deno-docs-green?logo=deno&color=informational)](https://doc.deno.land/https/deno.land/x/cabinet/mod.ts)
[![Docs](https://img.shields.io/badge/deno-module-red?logo=deno)](https://deno.land/x/cabinet)
[![nest badge](https://nest.land/badge-block.svg)](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)