All Projects → streamich → linkfs

streamich / linkfs

Licence: Unlicense License
Rewrite file system `fs` paths

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

linkfs

Redirects filesystem paths.

npm install --save linkfs
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.

const lfs = link(fs, ['/foo', '/bar']);

or

const lfs = link(fs, [
    ['/foo1', '/bar1'],
    ['/foo2', '/bar2'],
    ['/foo3', '/bar3'],
]);

License

Unlicense - public domain.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].