1 | "use strict";
|
---|
2 | var __assign = (this && this.__assign) || function () {
|
---|
3 | __assign = Object.assign || function(t) {
|
---|
4 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
---|
5 | s = arguments[i];
|
---|
6 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
---|
7 | t[p] = s[p];
|
---|
8 | }
|
---|
9 | return t;
|
---|
10 | };
|
---|
11 | return __assign.apply(this, arguments);
|
---|
12 | };
|
---|
13 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
14 | exports.fs = exports.createFsFromVolume = exports.vol = exports.Volume = void 0;
|
---|
15 | var Stats_1 = require("./Stats");
|
---|
16 | var Dirent_1 = require("./Dirent");
|
---|
17 | var volume_1 = require("./volume");
|
---|
18 | var _a = require('fs-monkey/lib/util/lists'), fsSyncMethods = _a.fsSyncMethods, fsAsyncMethods = _a.fsAsyncMethods;
|
---|
19 | var constants_1 = require("./constants");
|
---|
20 | var F_OK = constants_1.constants.F_OK, R_OK = constants_1.constants.R_OK, W_OK = constants_1.constants.W_OK, X_OK = constants_1.constants.X_OK;
|
---|
21 | exports.Volume = volume_1.Volume;
|
---|
22 | // Default volume.
|
---|
23 | exports.vol = new volume_1.Volume();
|
---|
24 | function createFsFromVolume(vol) {
|
---|
25 | var fs = { F_OK: F_OK, R_OK: R_OK, W_OK: W_OK, X_OK: X_OK, constants: constants_1.constants, Stats: Stats_1.default, Dirent: Dirent_1.default };
|
---|
26 | // Bind FS methods.
|
---|
27 | for (var _i = 0, fsSyncMethods_1 = fsSyncMethods; _i < fsSyncMethods_1.length; _i++) {
|
---|
28 | var method = fsSyncMethods_1[_i];
|
---|
29 | if (typeof vol[method] === 'function')
|
---|
30 | fs[method] = vol[method].bind(vol);
|
---|
31 | }
|
---|
32 | for (var _a = 0, fsAsyncMethods_1 = fsAsyncMethods; _a < fsAsyncMethods_1.length; _a++) {
|
---|
33 | var method = fsAsyncMethods_1[_a];
|
---|
34 | if (typeof vol[method] === 'function')
|
---|
35 | fs[method] = vol[method].bind(vol);
|
---|
36 | }
|
---|
37 | fs.StatWatcher = vol.StatWatcher;
|
---|
38 | fs.FSWatcher = vol.FSWatcher;
|
---|
39 | fs.WriteStream = vol.WriteStream;
|
---|
40 | fs.ReadStream = vol.ReadStream;
|
---|
41 | fs.promises = vol.promises;
|
---|
42 | fs._toUnixTimestamp = volume_1.toUnixTimestamp;
|
---|
43 | return fs;
|
---|
44 | }
|
---|
45 | exports.createFsFromVolume = createFsFromVolume;
|
---|
46 | exports.fs = createFsFromVolume(exports.vol);
|
---|
47 | module.exports = __assign(__assign({}, module.exports), exports.fs);
|
---|
48 | module.exports.semantic = true;
|
---|