9.2.1 • Published 15 days ago

@file-services/overlay v9.2.1

Weekly downloads
3,369
License
MIT
Repository
github
Last release
15 days ago

@file-services/overlay

Overlay files and directories from one file system on top of another.

Motivation

Overlay file system allows taking a native node file system ("lower fs") and overlay files and directories from an in-memory file system ("higher fs"). It can be used as a virtual layer providing a solution for storing and manipulating temporary data.

Behavior

Read operations (readFile, readdir, stat, etc.) are checking higher fs first, and fallback to lower fs.

Currently, all write operations go directly to the original lower fs.

Getting started

Install library in project:

npm i @file-services/overlay

Then, use the programmatic API:

import { createOverlayFs } from "@file-services/overlay";
import { createMemoryFs } from "@file-services/memory";
import { nodeFs } from "@file-services/node";

const memFs = createMemoryFs({
  src: {
    "a.txt": `A`,
    "b.txt": `B`,
  },
});

const overlayFs = createOverlayFs(nodeFs /* lower fs */, memFs /* higher fs */);

// overlayFs.readFileSync('src/a.txt', 'utf8') === 'A'

createOverlayFs also accepts a directory path as third parameter which specifies which directory in lower fs should be overlaid upon (defaults to lowerFs.cwd()). This is important when overlaying a memory fs over native node fs and running on Windows. Memory fs uses posix-style paths, so the base directory is where memory's root / begins to overlay.

License

MIT

9.2.1

15 days ago

9.2.0

1 month ago

9.1.0

2 months ago

9.0.0

2 months ago

8.3.2

7 months ago

8.3.1

8 months ago

8.1.3

9 months ago

8.3.3

6 months ago

8.1.0

9 months ago

8.0.1

9 months ago

8.0.0

9 months ago

8.3.0

8 months ago

8.1.2

9 months ago

8.2.0

8 months ago

8.1.1

9 months ago

7.4.0

11 months ago

7.3.0

1 year ago

7.2.5

1 year ago

7.2.4

1 year ago

7.2.3

1 year ago

7.2.2

1 year ago

7.2.0

1 year ago

7.0.0

2 years ago

7.0.1

2 years ago

6.0.0

2 years ago

5.7.1

2 years ago

5.7.0

2 years ago

5.4.0

3 years ago

5.3.1

3 years ago

5.3.0

3 years ago

5.2.1

3 years ago

5.2.0

3 years ago

5.1.0

3 years ago

5.0.0

3 years ago

4.1.0

4 years ago

4.0.0

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.0

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago