Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/streamich/linkfs
Rewrite file system `fs` paths
https://github.com/streamich/linkfs
Last synced: 3 months ago
JSON representation
Rewrite file system `fs` paths
- Host: GitHub
- URL: https://github.com/streamich/linkfs
- Owner: streamich
- License: unlicense
- Created: 2015-06-14T18:56:20.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-05-01T02:05:37.000Z (7 months ago)
- Last Synced: 2024-05-01T12:32:38.782Z (7 months ago)
- Language: TypeScript
- Size: 178 KB
- Stars: 52
- Watchers: 2
- Forks: 8
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# linkfs
Redirects filesystem paths.
[![][npm-img]][npm-url] [![][travis-badge]][travis-url]
npm install --save linkfs
```js
import {link} from 'linkfs';
import {fs} from 'memfs';fs.writeFileSync('/foo', 'bar');
const lfs = link(fs, ['/foo2', '/foo']);
console.log(lfs.readFileSync('/foo2', 'utf8')); // bar
```# Reference
### `link(fs, rewrites)`
Returns a new *fs-like* object with redirected file paths.
`fs` is the source *fs-like* object.
`rewrites` is a 2-tuple or an array of 2-tuples, where each 2-tuple
has a form of `[from, to]`. `from` is the new, *virtual* path; and `to`
is an existing path in the `fs` filesystem.```js
const lfs = link(fs, ['/foo', '/bar']);
```or
```js
const lfs = link(fs, [
['/foo1', '/bar1'],
['/foo2', '/bar2'],
['/foo3', '/bar3'],
]);
```[npm-url]: https://www.npmjs.com/package/linkfs
[npm-img]: https://img.shields.io/npm/v/linkfs.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/linkfs
[travis-badge]: https://travis-ci.org/streamich/linkfs.svg?branch=master# License
[Unlicense](./LICENSE) - public domain.