Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/streamich/unionfs
Use multiple fs modules at once
https://github.com/streamich/unionfs
filesystem fs union unionfs
Last synced: 7 days ago
JSON representation
Use multiple fs modules at once
- Host: GitHub
- URL: https://github.com/streamich/unionfs
- Owner: streamich
- License: unlicense
- Created: 2015-06-14T19:12:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-10-29T00:14:41.000Z (16 days ago)
- Last Synced: 2024-10-29T20:55:54.437Z (15 days ago)
- Topics: filesystem, fs, union, unionfs
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/unionfs
- Size: 2.53 MB
- Stars: 206
- Watchers: 8
- Forks: 24
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# unionfs
Creates a union of multiple `fs` file systems.
[![][npm-img]][npm-url] [![][travis-badge]][travis-url]
npm install --save unionfs
This module allows you to use multiple objects that have file system `fs` API at the same time.
```js
import { ufs } from 'unionfs';
import { fs as fs1 } from 'memfs';
import * as fs2 from 'fs';ufs.use(fs1).use(fs2);
ufs.readFileSync(/* ... */);
```Use this module with [`memfs`][memfs] and [`linkfs`][linkfs].
`memfs` allows you to create virtual in-memory file system. `linkfs` allows you to redirect `fs` paths.You can also use other _fs-like_ objects.
```js
import * as fs from 'fs';
import { Volume } from 'memfs';
import * as MemoryFileSystem from 'memory-fs';
import { ufs } from 'unionfs';const vol1 = Volume.fromJSON({ '/memfs-1': '1' });
const vol2 = Volume.fromJSON({ '/memfs-2': '2' });const memoryFs = new MemoryFileSystem();
memoryFs.writeFileSync('/memory-fs', '3');ufs.use(fs).use(vol1).use(vol2).use(memoryFs);
console.log(ufs.readFileSync('/memfs-1', 'utf8')); // 1
console.log(ufs.readFileSync('/memfs-2', 'utf8')); // 2
console.log(ufs.readFileSync('/memory-fs', 'utf8')); // 3
```You can create a `Union` instance manually:
```javascript
import { Union } from 'unionfs';var ufs1 = new Union();
ufs1.use(fs).use(vol);var ufs2 = new Union();
ufs2.use(fs).use(/*...*/);
```[npm-url]: https://www.npmjs.com/package/unionfs
[npm-img]: https://img.shields.io/npm/v/unionfs.svg
[memfs]: https://github.com/streamich/memfs
[unionfs]: https://github.com/streamich/unionfs
[linkfs]: https://github.com/streamich/linkfs
[fs-monkey]: https://github.com/streamich/fs-monkey
[travis-url]: https://travis-ci.org/streamich/unionfs
[travis-badge]: https://travis-ci.org/streamich/unionfs.svg?branch=master# License
[Unlicense](./LICENSE) - public domain.