memfs 3.1.2 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,37 @@
1
+ ## [3.2.2](https://github.com/streamich/memfs/compare/v3.2.1...v3.2.2) (2021-04-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency fs-monkey to v1.0.2 ([07f05db](https://github.com/streamich/memfs/commit/07f05db8b0aed43360abaf172d4297f3873d44fe))
7
+ * **deps:** update dependency fs-monkey to v1.0.3 ([84346ed](https://github.com/streamich/memfs/commit/84346ed7d0556b2b79f57b9b10889e54afcaebd1))
8
+
9
+ ## [3.2.1](https://github.com/streamich/memfs/compare/v3.2.0...v3.2.1) (2021-03-31)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * add `The Unlicense` license SDPX in package.json ([#594](https://github.com/streamich/memfs/issues/594)) ([0e7b04b](https://github.com/streamich/memfs/commit/0e7b04b0d5172846340e95619edaa18579ed5d06))
15
+
16
+ # [3.2.0](https://github.com/streamich/memfs/compare/v3.1.3...v3.2.0) (2020-05-19)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * 'fromJSON()' did not consider cwd when creating directories ([3d6ee3b](https://github.com/streamich/memfs/commit/3d6ee3b2c0eef0345ba2bd400e9836f2d685321f))
22
+
23
+
24
+ ### Features
25
+
26
+ * support nested objects in 'fromJSON()' ([f8c329c](https://github.com/streamich/memfs/commit/f8c329c8e57c85cc4a394a74802af1f37dcedefd))
27
+
28
+ ## [3.1.3](https://github.com/streamich/memfs/compare/v3.1.2...v3.1.3) (2020-05-14)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * **deps:** update dependency fs-monkey to v1.0.1 ([10fc705](https://github.com/streamich/memfs/commit/10fc705c46d57a4354afb9372a98dcdfed9d551d))
34
+
1
35
  ## [3.1.2](https://github.com/streamich/memfs/compare/v3.1.1...v3.1.2) (2020-03-12)
2
36
 
3
37
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # memfs
2
2
 
3
- [![][npm-badge]][npm-url] [![][travis-badge]][travis-url]
3
+ [![][chat-badge]][chat] [![][npm-badge]][npm-url] [![][travis-badge]][travis-url]
4
4
 
5
5
  In-memory file-system with [Node's `fs` API](https://nodejs.org/api/fs.html).
6
6
 
@@ -107,6 +107,8 @@ require('/index'); // hi world
107
107
  - [`fs-monkey`][fs-monkey] - monkey-patches Node's `fs` module and `require` function
108
108
  - [`libfs`](https://github.com/streamich/full-js/blob/master/src/lib/fs.ts) - real filesystem (that executes UNIX system calls) implemented in JavaScript
109
109
 
110
+ [chat]: https://onp4.com/@vadim/~memfs
111
+ [chat-badge]: https://img.shields.io/badge/Chat-%F0%9F%92%AC-green?style=flat&logo=chat&link=https://onp4.com/@vadim/~memfs
110
112
  [npm-url]: https://www.npmjs.com/package/memfs
111
113
  [npm-badge]: https://img.shields.io/npm/v/memfs.svg
112
114
  [travis-url]: https://travis-ci.org/streamich/memfs
package/lib/Dirent.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Dirent = void 0;
3
4
  var constants_1 = require("./constants");
4
5
  var encoding_1 = require("./encoding");
5
6
  var S_IFMT = constants_1.constants.S_IFMT, S_IFDIR = constants_1.constants.S_IFDIR, S_IFREG = constants_1.constants.S_IFREG, S_IFBLK = constants_1.constants.S_IFBLK, S_IFCHR = constants_1.constants.S_IFCHR, S_IFLNK = constants_1.constants.S_IFLNK, S_IFIFO = constants_1.constants.S_IFIFO, S_IFSOCK = constants_1.constants.S_IFSOCK;
package/lib/Stats.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Stats = void 0;
3
4
  var constants_1 = require("./constants");
4
5
  var getBigInt_1 = require("./getBigInt");
5
6
  var S_IFMT = constants_1.constants.S_IFMT, S_IFDIR = constants_1.constants.S_IFDIR, S_IFREG = constants_1.constants.S_IFREG, S_IFBLK = constants_1.constants.S_IFBLK, S_IFCHR = constants_1.constants.S_IFCHR, S_IFLNK = constants_1.constants.S_IFLNK, S_IFIFO = constants_1.constants.S_IFIFO, S_IFSOCK = constants_1.constants.S_IFSOCK;
package/lib/constants.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.constants = void 0;
3
4
  exports.constants = {
4
5
  O_RDONLY: 0,
5
6
  O_WRONLY: 1,
package/lib/encoding.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.strToEncoding = exports.assertEncoding = exports.ENCODING_UTF8 = void 0;
3
4
  var buffer_1 = require("./internal/buffer");
4
5
  var errors = require("./internal/errors");
5
6
  exports.ENCODING_UTF8 = 'utf8';
package/lib/index.js CHANGED
@@ -11,6 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.fs = exports.createFsFromVolume = exports.vol = exports.Volume = void 0;
14
15
  var Stats_1 = require("./Stats");
15
16
  var Dirent_1 = require("./Dirent");
16
17
  var volume_1 = require("./volume");
@@ -3,7 +3,7 @@ import { Buffer } from 'buffer';
3
3
  declare const bufferAllocUnsafe: (size: number) => Buffer;
4
4
  declare const bufferFrom: {
5
5
  (arrayBuffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number | undefined, length?: number | undefined): Buffer;
6
- (data: any[]): Buffer;
6
+ (data: readonly any[]): Buffer;
7
7
  (data: Uint8Array): Buffer;
8
8
  (obj: {
9
9
  valueOf(): string | object;
@@ -1,20 +1,19 @@
1
1
  "use strict";
2
- var __spreadArrays = (this && this.__spreadArrays) || function () {
3
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
4
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
5
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
6
- r[k] = a[j];
7
- return r;
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
3
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
4
+ to[j] = from[i];
5
+ return to;
8
6
  };
9
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.bufferFrom = exports.bufferAllocUnsafe = exports.Buffer = void 0;
10
9
  var buffer_1 = require("buffer");
11
- exports.Buffer = buffer_1.Buffer;
10
+ Object.defineProperty(exports, "Buffer", { enumerable: true, get: function () { return buffer_1.Buffer; } });
12
11
  function bufferV0P12Ponyfill(arg0) {
13
12
  var args = [];
14
13
  for (var _i = 1; _i < arguments.length; _i++) {
15
14
  args[_i - 1] = arguments[_i];
16
15
  }
17
- return new (buffer_1.Buffer.bind.apply(buffer_1.Buffer, __spreadArrays([void 0, arg0], args)))();
16
+ return new (buffer_1.Buffer.bind.apply(buffer_1.Buffer, __spreadArray([void 0, arg0], args)))();
18
17
  }
19
18
  var bufferAllocUnsafe = buffer_1.Buffer.allocUnsafe || bufferV0P12Ponyfill;
20
19
  exports.bufferAllocUnsafe = bufferAllocUnsafe;
@@ -8,16 +8,19 @@ var __extends = (this && this.__extends) || (function () {
8
8
  var extendStatics = function (d, b) {
9
9
  extendStatics = Object.setPrototypeOf ||
10
10
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
12
12
  return extendStatics(d, b);
13
13
  };
14
14
  return function (d, b) {
15
+ if (typeof b !== "function" && b !== null)
16
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
15
17
  extendStatics(d, b);
16
18
  function __() { this.constructor = d; }
17
19
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18
20
  };
19
21
  })();
20
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.E = exports.AssertionError = exports.message = exports.RangeError = exports.TypeError = exports.Error = void 0;
21
24
  var assert = require("assert");
22
25
  var util = require("util");
23
26
  var kCode = typeof Symbol === 'undefined' ? '_kCode' : Symbol('code');
package/lib/node.js CHANGED
@@ -3,16 +3,19 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
15
  };
14
16
  })();
15
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.File = exports.Link = exports.Node = exports.SEP = void 0;
16
19
  var process_1 = require("./process");
17
20
  var buffer_1 = require("./internal/buffer");
18
21
  var constants_1 = require("./constants");
package/lib/process.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  // Here we mock the global `process` variable in case we are not in Node's environment.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.createProcess = void 0;
4
5
  /**
5
6
  * Looks to return a `process` object, if one is available.
6
7
  *
package/lib/promises.js CHANGED
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
- var __spreadArrays = (this && this.__spreadArrays) || function () {
3
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
4
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
5
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
6
- r[k] = a[j];
7
- return r;
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
3
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
4
+ to[j] = from[i];
5
+ return to;
8
6
  };
9
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.FileHandle = void 0;
10
9
  function promisify(vol, fn, getResult) {
11
10
  if (getResult === void 0) { getResult = function (input) { return input; }; }
12
11
  return function () {
@@ -15,7 +14,7 @@ function promisify(vol, fn, getResult) {
15
14
  args[_i] = arguments[_i];
16
15
  }
17
16
  return new Promise(function (resolve, reject) {
18
- vol[fn].bind(vol).apply(void 0, __spreadArrays(args, [function (error, result) {
17
+ vol[fn].bind(vol).apply(void 0, __spreadArray(__spreadArray([], args), [function (error, result) {
19
18
  if (error)
20
19
  return reject(error);
21
20
  return resolve(getResult(result));
@@ -3,16 +3,19 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
15
  };
14
16
  })();
15
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.createVolume = exports.ObjectStore = void 0;
16
19
  var volume_1 = require("./volume");
17
20
  var node_1 = require("./node");
18
21
  var ObjectStore = /** @class */ (function () {
@@ -49,7 +52,7 @@ function createVolume(namespace, LS) {
49
52
  this._key = key('ino', this.ino);
50
53
  return this._key;
51
54
  },
52
- enumerable: true,
55
+ enumerable: false,
53
56
  configurable: true
54
57
  });
55
58
  NodeLocalStorage.prototype.sync = function () {
@@ -76,7 +79,7 @@ function createVolume(namespace, LS) {
76
79
  this._key = key('link', this.getPath());
77
80
  return this._key;
78
81
  },
79
- enumerable: true,
82
+ enumerable: false,
80
83
  configurable: true
81
84
  });
82
85
  LinkLocalStorage.prototype.sync = function () {
package/lib/volume.d.ts CHANGED
@@ -101,12 +101,19 @@ export declare function dataToStr(data: TData, encoding?: string): string;
101
101
  export declare function dataToBuffer(data: TData, encoding?: string): Buffer;
102
102
  export declare function bufferToEncoding(buffer: Buffer, encoding?: TEncodingExtended): TDataOut;
103
103
  export declare function toUnixTimestamp(time: any): any;
104
- export declare type DirectoryJSON = Record<string, string | null>;
104
+ declare type DirectoryContent = string | null;
105
+ export interface DirectoryJSON {
106
+ [key: string]: DirectoryContent;
107
+ }
108
+ export interface NestedDirectoryJSON {
109
+ [key: string]: DirectoryContent | NestedDirectoryJSON;
110
+ }
105
111
  /**
106
112
  * `Volume` represents a file system.
107
113
  */
108
114
  export declare class Volume {
109
115
  static fromJSON(json: DirectoryJSON, cwd?: string): Volume;
116
+ static fromNestedJSON(json: NestedDirectoryJSON, cwd?: string): Volume;
110
117
  /**
111
118
  * Global file descriptor counter. UNIX file descriptors start from 0 and go sequentially
112
119
  * up, so here, in order not to conflict with them, we choose some big number and descrease
@@ -163,6 +170,7 @@ export declare class Volume {
163
170
  private _toJSON;
164
171
  toJSON(paths?: PathLike | PathLike[], json?: {}, isRelative?: boolean): DirectoryJSON;
165
172
  fromJSON(json: DirectoryJSON, cwd?: string): void;
173
+ fromNestedJSON(json: NestedDirectoryJSON, cwd?: string): void;
166
174
  reset(): void;
167
175
  mountSync(mountpoint: string, json: DirectoryJSON): void;
168
176
  private openLink;
@@ -378,3 +386,4 @@ export declare class FSWatcher extends EventEmitter {
378
386
  start(path: PathLike, persistent?: boolean, recursive?: boolean, encoding?: BufferEncoding): void;
379
387
  close(): void;
380
388
  }
389
+ export {};
package/lib/volume.js CHANGED
@@ -3,23 +3,24 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
15
  };
14
16
  })();
15
- var __spreadArrays = (this && this.__spreadArrays) || function () {
16
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
17
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
18
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
19
- r[k] = a[j];
20
- return r;
17
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
18
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
19
+ to[j] = from[i];
20
+ return to;
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.FSWatcher = exports.StatWatcher = exports.Volume = exports.toUnixTimestamp = exports.bufferToEncoding = exports.dataToBuffer = exports.dataToStr = exports.pathToSteps = exports.filenameToSteps = exports.pathToFilename = exports.flagsToNumber = exports.FLAGS = void 0;
23
24
  var pathModule = require("path");
24
25
  var node_1 = require("./node");
25
26
  var Stats_1 = require("./Stats");
@@ -37,17 +38,7 @@ var util = require("util");
37
38
  var promises_1 = require("./promises");
38
39
  var resolveCrossPlatform = pathModule.resolve;
39
40
  var O_RDONLY = constants_1.constants.O_RDONLY, O_WRONLY = constants_1.constants.O_WRONLY, O_RDWR = constants_1.constants.O_RDWR, O_CREAT = constants_1.constants.O_CREAT, O_EXCL = constants_1.constants.O_EXCL, O_TRUNC = constants_1.constants.O_TRUNC, O_APPEND = constants_1.constants.O_APPEND, O_SYNC = constants_1.constants.O_SYNC, O_DIRECTORY = constants_1.constants.O_DIRECTORY, F_OK = constants_1.constants.F_OK, COPYFILE_EXCL = constants_1.constants.COPYFILE_EXCL, COPYFILE_FICLONE_FORCE = constants_1.constants.COPYFILE_FICLONE_FORCE;
40
- var sep;
41
- var relative;
42
- if (pathModule.posix) {
43
- var posix = pathModule.posix;
44
- sep = posix.sep;
45
- relative = posix.relative;
46
- }
47
- else {
48
- sep = pathModule.sep;
49
- relative = pathModule.relative;
50
- }
41
+ var _a = pathModule.posix ? pathModule.posix : pathModule, sep = _a.sep, relative = _a.relative, join = _a.join, dirname = _a.dirname;
51
42
  var isWin = process_1.default.platform === 'win32';
52
43
  var kMinPoolSpace = 128;
53
44
  // const kMaxLength = require('buffer').kMaxLength;
@@ -409,6 +400,29 @@ function validateGid(gid) {
409
400
  if (typeof gid !== 'number')
410
401
  throw TypeError(ERRSTR.GID);
411
402
  }
403
+ function flattenJSON(nestedJSON) {
404
+ var flatJSON = {};
405
+ function flatten(pathPrefix, node) {
406
+ for (var path in node) {
407
+ var contentOrNode = node[path];
408
+ var joinedPath = join(pathPrefix, path);
409
+ if (typeof contentOrNode === 'string') {
410
+ flatJSON[joinedPath] = contentOrNode;
411
+ }
412
+ else if (typeof contentOrNode === 'object' && contentOrNode !== null && Object.keys(contentOrNode).length > 0) {
413
+ // empty directories need an explicit entry and therefore get handled in `else`, non-empty ones are implicitly considered
414
+ flatten(joinedPath, contentOrNode);
415
+ }
416
+ else {
417
+ // without this branch null, empty-object or non-object entries would not be handled in the same way
418
+ // by both fromJSON() and fromNestedJSON()
419
+ flatJSON[joinedPath] = null;
420
+ }
421
+ }
422
+ }
423
+ flatten('', nestedJSON);
424
+ return flatJSON;
425
+ }
412
426
  /**
413
427
  * `Volume` represents a file system.
414
428
  */
@@ -451,7 +465,7 @@ var Volume = /** @class */ (function () {
451
465
  for (var _i = 0; _i < arguments.length; _i++) {
452
466
  args[_i] = arguments[_i];
453
467
  }
454
- return _super.apply(this, __spreadArrays([self], args)) || this;
468
+ return _super.apply(this, __spreadArray([self], args)) || this;
455
469
  }
456
470
  return class_1;
457
471
  }(_ReadStream));
@@ -463,7 +477,7 @@ var Volume = /** @class */ (function () {
463
477
  for (var _i = 0; _i < arguments.length; _i++) {
464
478
  args[_i] = arguments[_i];
465
479
  }
466
- return _super.apply(this, __spreadArrays([self], args)) || this;
480
+ return _super.apply(this, __spreadArray([self], args)) || this;
467
481
  }
468
482
  return class_2;
469
483
  }(_WriteStream));
@@ -485,13 +499,18 @@ var Volume = /** @class */ (function () {
485
499
  vol.fromJSON(json, cwd);
486
500
  return vol;
487
501
  };
502
+ Volume.fromNestedJSON = function (json, cwd) {
503
+ var vol = new Volume();
504
+ vol.fromNestedJSON(json, cwd);
505
+ return vol;
506
+ };
488
507
  Object.defineProperty(Volume.prototype, "promises", {
489
508
  get: function () {
490
509
  if (this.promisesApi === null)
491
510
  throw new Error('Promise is not supported in this environment.');
492
511
  return this.promisesApi;
493
512
  },
494
- enumerable: true,
513
+ enumerable: false,
495
514
  configurable: true
496
515
  });
497
516
  Volume.prototype.createLink = function (parent, name, isDirectory, perm) {
@@ -728,18 +747,14 @@ var Volume = /** @class */ (function () {
728
747
  }
729
748
  return json;
730
749
  };
731
- // fromJSON(json: {[filename: string]: string}, cwd: string = '/') {
732
750
  Volume.prototype.fromJSON = function (json, cwd) {
733
751
  if (cwd === void 0) { cwd = process_1.default.cwd(); }
734
752
  for (var filename in json) {
735
753
  var data = json[filename];
754
+ filename = resolve(filename, cwd);
736
755
  if (typeof data === 'string') {
737
- filename = resolve(filename, cwd);
738
- var steps = filenameToSteps(filename);
739
- if (steps.length > 1) {
740
- var dirname = sep + steps.slice(0, steps.length - 1).join(sep);
741
- this.mkdirpBase(dirname, 511 /* DIR */);
742
- }
756
+ var dir = dirname(filename);
757
+ this.mkdirpBase(dir, 511 /* DIR */);
743
758
  this.writeFileSync(filename, data);
744
759
  }
745
760
  else {
@@ -747,6 +762,9 @@ var Volume = /** @class */ (function () {
747
762
  }
748
763
  }
749
764
  };
765
+ Volume.prototype.fromNestedJSON = function (json, cwd) {
766
+ this.fromJSON(flattenJSON(json), cwd);
767
+ };
750
768
  Volume.prototype.reset = function () {
751
769
  this.ino = 0;
752
770
  this.inodes = {};
@@ -1279,7 +1297,7 @@ var Volume = /** @class */ (function () {
1279
1297
  }
1280
1298
  // Rename should overwrite the new path, if that exists.
1281
1299
  var name = newPathSteps[newPathSteps.length - 1];
1282
- link.steps = __spreadArrays(newPathDirLink.steps, [name]);
1300
+ link.steps = __spreadArray(__spreadArray([], newPathDirLink.steps), [name]);
1283
1301
  newPathDirLink.setChild(link.getName(), link);
1284
1302
  };
1285
1303
  Volume.prototype.renameSync = function (oldPath, newPath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memfs",
3
- "version": "3.1.2",
3
+ "version": "3.2.2",
4
4
  "description": "In-memory file-system with Node's fs API.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -23,26 +23,26 @@
23
23
  "url": "https://github.com/streamich/memfs.git"
24
24
  },
25
25
  "dependencies": {
26
- "fs-monkey": "1.0.0"
26
+ "fs-monkey": "1.0.3"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/jest": "23.3.14",
30
- "@types/node": "10.17.17",
31
- "cpy-cli": "3.1.0",
32
- "husky": "3.1.0",
33
- "jest": "24.9.0",
34
- "prettier": "1.19.1",
35
- "pretty-quick": "2.0.1",
29
+ "@types/jest": "26.0.22",
30
+ "@types/node": "10.17.56",
31
+ "cpy-cli": "3.1.1",
32
+ "husky": "6.0.0",
33
+ "jest": "26.6.3",
34
+ "prettier": "2.2.1",
35
+ "pretty-quick": "3.1.0",
36
36
  "rimraf": "3.0.2",
37
- "ts-jest": "24.3.0",
38
- "ts-node": "8.6.2",
37
+ "ts-jest": "26.5.4",
38
+ "ts-node": "9.1.1",
39
39
  "tslint": "5.20.1",
40
40
  "tslint-config-common": "1.6.0",
41
- "typescript": "3.8.3",
42
- "semantic-release": "15.14.0",
43
- "@semantic-release/changelog": "3.0.6",
44
- "@semantic-release/git": "7.0.18",
45
- "@semantic-release/npm": "5.3.5"
41
+ "typescript": "4.2.3",
42
+ "semantic-release": "17.4.2",
43
+ "@semantic-release/changelog": "5.0.1",
44
+ "@semantic-release/git": "9.0.0",
45
+ "@semantic-release/npm": "7.1.0"
46
46
  },
47
47
  "config": {
48
48
  "commitizen": {
@@ -56,6 +56,7 @@
56
56
  "js",
57
57
  "jsx"
58
58
  ],
59
+ "testEnvironment": "node",
59
60
  "transform": {
60
61
  "^.+\\.tsx?$": "ts-jest"
61
62
  },
@@ -76,6 +77,7 @@
76
77
  "@semantic-release/git"
77
78
  ]
78
79
  },
80
+ "license": "Unlicense",
79
81
  "keywords": [
80
82
  "fs",
81
83
  "filesystem",