# asyncplify-fs

> asyncplify wrappers around some of the node fs lib

Latest version **0.5.3** (published 2015-07-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install asyncplify-fs
pnpm add asyncplify-fs
yarn add asyncplify-fs
bun add asyncplify-fs
```

## 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.5.3 |
| Published | 2015-07-22 |
| First published | 2015-05-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dany Laporte |
| Maintainers | danylaporte |
| Keywords | asyncplify, fs, file, directory |

## Links

- npm: https://www.npmjs.com/package/asyncplify-fs
- Repository: https://github.com/danylaporte/asyncplify-fs
- Issues: https://github.com/danylaporte/asyncplify-fs/issues
- npm.io page: https://npm.io/package/asyncplify-fs

## Dependencies (3)

- [temp](https://npm.io/package/temp.md) ^0.8.3
- [debug](https://npm.io/package/debug.md) ^2.2.0
- [asyncplify](https://npm.io/package/asyncplify.md) ^0.5.8

## 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.5.3 (latest) — 2015-07-22
- 0.5.2 — 2015-07-16
- 0.5.1 — 2015-07-15
- 0.5.0 — 2015-07-10
- 0.0.5 — 2015-06-12
- 0.0.4 — 2015-06-11
- 0.0.3 — 2015-06-08
- 0.0.2 — 2015-05-27
- 0.0.1 — 2015-05-24

## README

# asyncplify-fs
[asyncplify](https://github.com/danylaporte/asyncplify) wrappers around some of the node fs lib

## Installation

```bash
npm install asyncplify-fs
```

## Documentation

### fromPaged(options)
Asynchronously reads multiple files from disk and returns the items.

options:
- autoDelete Boolean default = false
- filenames Array

Example:
```js
fs.writeFileSync('page1.json', [1, 2]);
fs.writeFileSync('page2.json', [3, 4]);

asyncplifyFs
	.fromPaged(['page1.json', 'page2.json'])
	.subscribe({
		emit: function (data) {
			console.log(data);
		},
		end: function (err) {
			if (err) throw err;
		}
	});
    
    // 1
    // 2
    // 3
    // 4
    // end.
```
When autoDelete = true, the the files are automatically deleted from the disk once loaded.

### readFile(options)
Asynchronously reads the entire contents of a file. 

options:
- path String
- encoding 	String | Null default = null
- flag		String default = 'r'

Example:
```js
asyncplifyFs
	.readFile('/etc/passwd')
	.subscribe({
		emit: function (data) {
			console.log(data);
		},
		end: function (err) {
			if (err) throw err;
		}
	});
```

### toPaged(options)
Asynchronously write a page of items to files on disk and returns the filename.
The filenames are generated based on temp folder.

options:
- beforeSaving Function
- size Number default = 0

Example:
```js
asyncplify
	.fromArray([0, 1, 2, 3, 4, 5])
	.pipe(asyncplifyFs.toPaged(2))
	.subscribe(emit: console.bind(console));

    // /user/temp/1231nnuukkasdppasd
	// /user/temp/488fdjj31n324nuukd-sspsd
	// /user/temp/9003403mmfjue003-llhpt
    // end.
```
The beforeSaving functions allow to transform the items prior to saving, such as sorting, etc.
When the size is not provided, the method will produce a single page containing all items.


### writeFile(options)
Asynchronously writes data to a file, replacing the file if it already exists. data can be a string or a buffer.

options:
- path String
- data String | Buffer
- encoding 	String | Null default = 'utf8'
- mode 		Number default = 438
- flag		String default = 'w'

Example:
```js
asyncplifyFs
	.writeFile({
		path: 'message.txt',
		data: 'Hello asyncplify'
	})
	.subscribe({
		emit: function (data) {
			console.log(data);
		},
		end: function (err) {
			if (err) throw err;
		}
	});
```
## License
The MIT License (MIT)

Copyright (c) 2015 Dany Laporte

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