# file-save

> auto create path and just save the file!

Latest version **0.2.0** (published 2014-07-08) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2014-07-08 |
| First published | 2014-02-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | chilijung |
| Maintainers | chilijung |
| Keywords | file, save |

## Links

- npm: https://www.npmjs.com/package/file-save
- Repository: git@github.com:chilijung/file-save
- Homepage: https://github.com/chilijung/file-save
- Issues: https://github.com/chilijung/file-save/issues
- npm.io page: https://npm.io/package/file-save

## Dependencies (1)

- [mkdirp](https://npm.io/package/mkdirp.md) ~0.5.0

## 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.2.0 (latest) — 2014-07-08
- 0.1.1 — 2014-02-16
- 0.1.0 — 2014-02-15

## README

# Streaming saving file

[![Build Status](https://travis-ci.org/chilijung/file-save.png)](https://travis-ci.org/chilijung/file-save)

Streaming data to file and save it using Stream.(the module will make directory itself if the directory is not exist).

## Install

```
npm install file-save
```

## Example

```javascript
var fileSave = require('file-save');

// the first line will create a writeStream to the file path
fileSave('sample/test')
    .write('this is the first line', 'utf8')
    .write('this is the second line', 'utf8', function() {
        console.log('writer callback')
    })
    .end('this is the end')
    .error(function() {
        console.log('error goes here')
    })
    .finish(function() {
        console.log('write finished.')
    })
```

## Usage

```
fileSave(<filename>)
```

`file-save` module will build a write stream to the file, and automatically make directory if the directory is not exist and need to create.

## Chaining methods

#### .write(chunk, [encoding], [callbak])

- chunk (string)
- encoding (string): like the encoding settings in writeable stream. http://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback 
- callback (function): callback function settings in writeable http://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback

#### .end([string], [encoding], [callback])

Same as `.write` method, but string is also optional.

#### .error(callback)

You can make a callback, while the stream prompt error

see more: http://nodejs.org/api/stream.html#stream_event_error_1

#### .finish(callback)

Make a callback while finished, **using this method you have to call ** `.foot` **before calling this method**

see more: http://nodejs.org/api/stream.html#stream_event_finish

## License

MIT [@chilijung](http://github.com/chilijung)

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