# file-chain

> fluent api for File operations, with concurrency safe read/writes & plugins

Latest version **0.0.3** (published 2017-04-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install file-chain
pnpm add file-chain
yarn add file-chain
bun add file-chain
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2017-04-30 |
| First published | 2017-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | James |
| Maintainers | aretecode |
| Keywords | fluent, chainable, file, read, write, fliphub, safe, path, fs |

## Links

- npm: https://www.npmjs.com/package/file-chain
- Repository: https://github.com/aretecode/file-chain
- Homepage: https://github.com/aretecode/file-chain#readme
- Issues: https://github.com/aretecode/file-chain/issues
- npm.io page: https://npm.io/package/file-chain

## Dependencies (6)

- [flipfile](https://npm.io/package/flipfile.md) *
- [flipfind](https://npm.io/package/flipfind.md) *
- [sleepfor](https://npm.io/package/sleepfor.md) *
- [flipchain](https://npm.io/package/flipchain.md) *
- [likeaboss](https://npm.io/package/likeaboss.md) *
- [json-chain](https://npm.io/package/json-chain.md) *

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 0.0.3 (latest) — 2017-04-30
- 0.0.2 — 2017-04-18
- 0.0.1 — 2017-04-18

## README

# 📒⛓ file-chain

[![NPM version][file-chain-image]][file-chain-url]
[![MIT License][license-image]][license-url]
[![fliphub][gitter-badge]][gitter-url]
[![flipfam][flipfam-image]][flipfam-url]

[file-chain-image]: https://img.shields.io/npm/v/file-chain.svg
[file-chain-url]: https://npmjs.org/package/file-chain
[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: https://spdx.org/licenses/MIT
[gitter-badge]: https://img.shields.io/gitter/room/fliphub/pink.svg
[gitter-url]: https://gitter.im/fliphub/Lobby
[flipfam-image]: https://img.shields.io/badge/%F0%9F%8F%97%20%F0%9F%92%A0-flipfam-9659F7.svg
[flipfam-url]: https://www.npmjs.com/package/flipfam

> fluent api for File operations, with concurrency safe read/writes & plugins

## 📦 install
```bash
yarn add file-chain
npm i file-chain --save
```

### 👽 use

```js
const File = require('file-chain')

// can also import destructured
// const {File} = require('file-chain')
```

## 📘 examples


```js
const datas = File
  .init()
  .dir(__dirname)
  .src('./index.js')
  .load()
  .json()
  .setIfNotEmpty({eh: true})
  .update({moose: true})
  .parse() // optional, is done for you
  .clean()
  .write()

const stats = datas
  .getStats() // read stats
  .del() // delete file
  .info() // stats are already loaded

```

### 👣 dir

```js
const file = File
  .src('./index.js')
  .dir(__dirname)
  .load(true)
  .setContent('...')
  .prependContent('alpha')
  .appendContent('omega')
  .write() // alpha...omega
```

### 🔌 plugins

```js
const plugin = {
  setContentToMagic() {
    this.contents = 'magic'
    return this
  }
}

const file = new File()

file
  .use(plugin)
  .src('./index.js')
  .dir(__dirname)
  .setContentToMagic()
  .write()
```


## 🔗 more
- for json, [json-chain][json-chain] is used
- for resolving paths (unless .dir is used), [flipfind][flipfind] is used
- for all fs operations, [flipfile][flipfile] is used
- for all chaining, [flipchain][flipchain] is used

[json-chain]: https://www.npmjs.com/package/json-chain
[flipfind]: https://www.npmjs.com/package/flipfind
[flipfile]: https://www.npmjs.com/package/flipfile
[flipchain]: https://www.npmjs.com/package/flipchain

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