# node-browserfs

> a node fs-like browser in-memory file system

Latest version **3.0.1** (published 2016-11-13) · WTFPL license · 0 weekly downloads

## Install

```sh
npm install node-browserfs
pnpm add node-browserfs
yarn add node-browserfs
bun add node-browserfs
```

## 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 | 3.0.1 |
| Published | 2016-11-13 |
| First published | 2014-11-24 |
| Weekly downloads | 0 |
| License | WTFPL |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | kruemelo |
| Maintainers | kruemelo |
| Keywords | node, fs, browser |

## Links

- npm: https://www.npmjs.com/package/node-browserfs
- Repository: https://github.com/kruemelo/node-browserfs
- Homepage: https://github.com/kruemelo/node-browserfs#readme
- Issues: https://github.com/kruemelo/node-browserfs/issues
- npm.io page: https://npm.io/package/node-browserfs

## 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

- 3.0.1 (latest) — 2016-11-13
- 3.0.0 — 2016-11-13
- 2.1.0 — 2016-11-08
- 1.4.11 — 2016-11-06
- 1.4.10 — 2016-11-06
- 1.4.9 — 2016-05-11
- 1.4.8 — 2016-04-07
- 1.4.7 — 2016-01-25
- 1.4.6 — 2015-12-01
- 1.4.5 — 2015-11-30
- 1.4.4 — 2015-11-30
- 1.4.3 — 2015-11-29
- 1.4.2 — 2015-11-28
- 1.4.1 — 2015-11-27
- 1.4.0 — 2015-11-27
- … 9 more at https://npm.io/package/node-browserfs/versions

## README

node-BrowserFs
==============

a node fs-like browser in-memory file system. Synchronous & async versions available for all supported functions.

API
---

http://nodejs.org/api/fs.html

plus:
  * rmrf [rimraf](https://www.npmjs.org/package/rimraf)
  * [mkdirp](https://www.npmjs.org/package/mkdirp)
  * [join([path1], [path2], [...])](http://nodejs.org/api/path.html#path_path_join_path1_path2)
  * parsePathParts('/a/b/../c') -> ['a', 'c']
  * fileSizeSI / fileSizeIEC -> 34.30 kB / 33.50 KiB
  * [BrowserFs.Buffer](https://nodejs.org/docs/latest-v5.x/api/buffer.html)
  * [BrowserFs.path](https://nodejs.org/docs/latest-v5.x/api/path.html)

not supported:
  * watch, unwatch
  * stream
  * appendFile
  * chmod, chown
  * open, read, write, close
  * fsync
  * truncate
  * link, symlink
  * realpath


Use
---
```
var BrowserFs = requirejs('BrowserFs');
var fs = new BrowserFs();

fs.statSync('/');
fs.mkdirSync('/subdir');
fs.mkdirpSync('/subdir2/subdir3');
fs.existsSync('/subdir/subdir2');
fs.rmdirSync('/subdir/subdir2');
fs.rmrfSync('/subdir');
fs.writeFileSync('/file', 'file string content');
fs.writeFileSync('/file', buffer);


fs.stat('/file', function (err, stats) {
  // human readable file size:
  // SI: kB,MB,GB,TB,PB,EB,ZB,YB / IEC: KiB,MiB,GiB,TiB,PiB,EiB,ZiB,YiB
  console.log(fs.fileSizeSI(stats.size), fs.fileSizeIEC(stats.size));
  // -> 34.30 kB / 33.50 KiB
});

// async example Asynchronous readdir(3)
// see node js fs api http://nodejs.org/api/fs.html#fs_fs_readdir_path_callback
fs.readdir('/', function (err, files) {
  ...
});

// Asynchronous rename(2) / move directory (or file)
fs.rename('/subdir1/subdir1-1', '/subdir2/subdir2-1', function (err) {
  ...
});

// fs.access(path[, mode], callback)
fs.access('/path/to/file', function (err) {
  ...
});

// access to node path

BrowserFs.path.join(''/a/b', '../c');  // '/a/c'
BrowserFs.path.normalize('/a/b/..c');  // '/a/c'

// access to node Buffer
vart buf = BrowserFs.Buffer.from('tést', 'utf8'); 
buf.toString('utf8'); // 'tést'

```

Have a look at the example folder.

Open index.html in browser, drop the github timeout png, click on the filename to download..

Read the code.

Test
----

```
$ mocha
```

Build
-----

Prerequisites

+ `node -v` >= 5.12.0
+ `npm install browserify -g`

run `npm run build` will produce browserified version of `lib/BrowserFs.js` in main folder `BrowserFs.js' and minify to 'BrowserFs.min.js'


License
-------
[WTFPL](http://www.wtfpl.net/)

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