# @hackbg/file

> File utilities.

Latest version **3.0.0-rc.5** (published 2024-02-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @hackbg/file
pnpm add @hackbg/file
yarn add @hackbg/file
bun add @hackbg/file
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.0-rc.5 |
| Published | 2024-02-28 |
| First published | 2023-02-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 11 |
| Unpacked size | 41 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | exactlywhoyouthinkitis, denismaxim0v, aakamenov, atanas-krondev, imollov, mradkov |

## Links

- npm: https://www.npmjs.com/package/@hackbg/file
- Repository: https://github.com/hackbg/toolbox
- Issues: https://github.com/hackbg/toolbox/issues
- npm.io page: https://npm.io/package/@hackbg/file

## Dependencies (11)

- [tmp](https://npm.io/package/tmp.md) ^0.2.1
- [toml](https://npm.io/package/toml.md) ^3.0.0
- [mkdirp](https://npm.io/package/mkdirp.md) ^1.0.4
- [rimraf](https://npm.io/package/rimraf.md) ^3.0.2
- [js-yaml](https://npm.io/package/js-yaml.md) ^4.1.0
- [@folder/xdg](https://npm.io/package/@folder/xdg.md) ^4.0.1
- [symlink-dir](https://npm.io/package/symlink-dir.md) ^5.2.0
- [@hackbg/4mat](https://npm.io/package/@hackbg/4mat.md) ^3.0.0
- [@hackbg/hide](https://npm.io/package/@hackbg/hide.md) ^1.0.3
- [@hackbg/logs](https://npm.io/package/@hackbg/logs.md) ^2.3.0
- [recursive-copy](https://npm.io/package/recursive-copy.md) ^2.0.14

## Recent versions

- 3.0.0-rc.5 (latest) — 2024-02-28
- 3.0.0-rc.4 — 2024-01-20
- 3.0.0-rc.3 — 2024-01-20
- 3.0.0-rc.2 — 2024-01-17
- 3.0.0-rc.1 — 2024-01-17
- 2.0.3 — 2023-12-05
- 2.0.2 — 2023-12-05
- 2.0.1 — 2023-11-28
- 2.0.0 — 2023-11-08
- 1.2.3 — 2023-08-24
- 1.2.2 — 2023-05-12
- 1.2.0 — 2023-05-04
- 1.1.0 — 2023-04-26
- 1.0.0 — 2023-02-23

## README

# @hackbg/file

**Filesystem utilities.**

Your OS's filesystem isn't the most powerful database,
it's one of the more familiar and human-friendly ones out there.

This package exports:

* The `$` helper function, which concatenates paths.
* The `File` and `Directory` classes, which you can use to
  specify whether you expect a file or a directory at a given path.
* The `JSONFile`, `YAMLFile` etc. subclasses for automatically
  loading data in a given format.
* Reexports `fs`, `fs/promises`, as well as `mkdirp` and `rimraf`.

```javascript
import $, { Directory, TextFile, JSONFile } from '@hackbg/file'

const root = $(process.cwd())

// Access files through a directory
const dir = root.in('data').as(Directory).make()
dir.at('file.txt').as(TextFile).save('my data')
dir.at('file.json').as(JSONFile).save({my:'data'})
console.log(dir.list())

// Or directly
console.log(new JSONFile(root, 'data', 'file.json').load())
console.log(root.in('data').at('file.txt').as(TextFile).load())
```

<div align="center">

---

Made with **#%&!** @ [**Hack.bg**](https://foss.hack.bg)

</div>

---
_Source: https://npm.io/package/@hackbg/file · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
