1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.memfs = exports.fs = exports.createFsFromVolume = exports.vol = exports.Volume = void 0;
|
4 | const Stats_1 = require("./Stats");
|
5 | const Dirent_1 = require("./Dirent");
|
6 | const volume_1 = require("./volume");
|
7 | const constants_1 = require("./constants");
|
8 | const fsSynchronousApiList_1 = require("./node/lists/fsSynchronousApiList");
|
9 | const fsCallbackApiList_1 = require("./node/lists/fsCallbackApiList");
|
10 | const { F_OK, R_OK, W_OK, X_OK } = constants_1.constants;
|
11 | exports.Volume = volume_1.Volume;
|
12 |
|
13 | exports.vol = new volume_1.Volume();
|
14 | function createFsFromVolume(vol) {
|
15 | const fs = { F_OK, R_OK, W_OK, X_OK, constants: constants_1.constants, Stats: Stats_1.default, Dirent: Dirent_1.default };
|
16 |
|
17 | for (const method of fsSynchronousApiList_1.fsSynchronousApiList)
|
18 | if (typeof vol[method] === 'function')
|
19 | fs[method] = vol[method].bind(vol);
|
20 | for (const method of fsCallbackApiList_1.fsCallbackApiList)
|
21 | if (typeof vol[method] === 'function')
|
22 | fs[method] = vol[method].bind(vol);
|
23 | fs.StatWatcher = vol.StatWatcher;
|
24 | fs.FSWatcher = vol.FSWatcher;
|
25 | fs.WriteStream = vol.WriteStream;
|
26 | fs.ReadStream = vol.ReadStream;
|
27 | fs.promises = vol.promises;
|
28 | fs._toUnixTimestamp = volume_1.toUnixTimestamp;
|
29 | fs.__vol = vol;
|
30 | return fs;
|
31 | }
|
32 | exports.createFsFromVolume = createFsFromVolume;
|
33 | exports.fs = createFsFromVolume(exports.vol);
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | const memfs = (json = {}, cwd = '/') => {
|
45 | const vol = exports.Volume.fromNestedJSON(json, cwd);
|
46 | const fs = createFsFromVolume(vol);
|
47 | return { fs, vol };
|
48 | };
|
49 | exports.memfs = memfs;
|
50 | module.exports = Object.assign(Object.assign({}, module.exports), exports.fs);
|
51 | module.exports.semantic = true;
|
52 |
|
\ | No newline at end of file |