# co-file

> co file handlers in node

Latest version **2.0.7** (published 2017-03-28) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.7 |
| Published | 2017-03-28 |
| First published | 2017-03-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | liuyuanyang |
| Maintainers | antfoot |
| Keywords | co, file, handlers, node |

## Links

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

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads
- [datasets-fi-postalcodes](https://npm.io/package/datasets-fi-postalcodes.md) — 1.1K weekly downloads

## Recent versions

- 2.0.7 (latest) — 2017-03-28
- 2.0.6 — 2017-03-22
- 2.0.5 — 2017-03-22
- 2.0.4 — 2017-03-22
- 2.0.3 — 2017-03-22
- 2.0.2 — 2017-03-22
- 2.0.0 — 2017-03-22
- 1.0.3 — 2017-03-22
- 1.0.2 — 2017-03-21
- 1.0.1 — 2017-03-21
- 1.0.0 — 2017-03-21

## README

## Abandoned...till 2.0.7

`co-file` provides some file handlers in node.

## What

It provides:

+   create file/folder
+   remove file/folder
+   copy file/folder
+   read file/folder

## How

```
const coFile = require('co-file');
```

+   create file

```
co(function*() {
    yield coFile.create(srcFileOrFolderPath);
});
```

**srcFileOrFolderPath** should be an absolute path.



+   remove file/folder

```
co(function*() {
    yield coFile.remove(srcFileOrFolderPath);
});
```

**srcFileOrFolderPath** should be an absolute path.

+   copy file/folder

```
co(function*() {
    yield coFile.copy(srcFileOrFolderPath, targetFolderPath);
});
```

**srcFileOrFolderPath** and **targetFolderPath** should be absolute paths.



+   read file/folder

```
co(function*() {
    yield coFile.read(srcFileOrFolderPath, function(dirPath, files) {
    
        // callback when read dir.
        // dirPath: absolute dir path
        // files: array of filename
        
    }, function (filePath, fileContentBuffer) {
    
        // callback when read file.
        // filePath: absolute file path
        // fileContentBuffer: file content buffer, you can use `fileContentBuffer.toString()` to make it to string.
        
    });
});
```

**srcFileOrFolderPath** should be an absolute path.

## Test

`npm run test`

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