memfs 4.9.1 → 5.0.0-next.1

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.
Files changed (173) hide show
  1. package/lib/Dirent.js +0 -1
  2. package/lib/Stats.js +0 -1
  3. package/lib/cas/types.js +0 -1
  4. package/lib/constants.js +0 -1
  5. package/lib/consts/AMODE.js +0 -1
  6. package/lib/consts/FLAG.js +0 -1
  7. package/lib/crud/types.js +0 -1
  8. package/lib/crud/util.js +0 -1
  9. package/lib/crud-to-cas/CrudCas.js +0 -1
  10. package/lib/crud-to-cas/CrudCasBase.js +1 -2
  11. package/lib/crud-to-cas/index.js +0 -1
  12. package/lib/crud-to-cas/util.js +0 -1
  13. package/lib/encoding.js +0 -1
  14. package/lib/fsa/types.js +0 -1
  15. package/lib/fsa-to-crud/FsaCrud.js +20 -65
  16. package/lib/fsa-to-crud/index.js +0 -1
  17. package/lib/fsa-to-crud/util.js +0 -1
  18. package/lib/fsa-to-node/FsaNodeCore.js +0 -1
  19. package/lib/fsa-to-node/FsaNodeDirent.js +0 -1
  20. package/lib/fsa-to-node/FsaNodeFs.js +16 -60
  21. package/lib/fsa-to-node/FsaNodeFsOpenFile.js +0 -1
  22. package/lib/fsa-to-node/FsaNodeReadStream.js +0 -1
  23. package/lib/fsa-to-node/FsaNodeStats.js +0 -1
  24. package/lib/fsa-to-node/FsaNodeWriteStream.js +2 -4
  25. package/lib/fsa-to-node/constants.js +0 -1
  26. package/lib/fsa-to-node/index.js +0 -1
  27. package/lib/fsa-to-node/json.js +0 -1
  28. package/lib/fsa-to-node/types.js +0 -1
  29. package/lib/fsa-to-node/util.js +1 -2
  30. package/lib/fsa-to-node/worker/FsaNodeSyncAdapterWorker.js +0 -1
  31. package/lib/fsa-to-node/worker/FsaNodeSyncWorker.js +3 -4
  32. package/lib/fsa-to-node/worker/SyncMessenger.js +1 -2
  33. package/lib/fsa-to-node/worker/constants.js +0 -1
  34. package/lib/fsa-to-node/worker/types.js +0 -1
  35. package/lib/index.js +1 -2
  36. package/lib/internal/buffer.js +0 -1
  37. package/lib/internal/errors.js +0 -1
  38. package/lib/node/FileHandle.js +0 -1
  39. package/lib/node/FsPromises.js +0 -1
  40. package/lib/node/constants.js +0 -1
  41. package/lib/node/lists/fsCallbackApiList.js +0 -1
  42. package/lib/node/lists/fsCommonObjectsList.js +0 -1
  43. package/lib/node/lists/fsSynchronousApiList.js +0 -1
  44. package/lib/node/options.js +0 -1
  45. package/lib/node/types/FsCallbackApi.js +0 -1
  46. package/lib/node/types/FsCommonObjects.js +0 -1
  47. package/lib/node/types/FsPromisesApi.js +0 -1
  48. package/lib/node/types/FsSynchronousApi.js +0 -1
  49. package/lib/node/types/index.js +0 -1
  50. package/lib/node/types/misc.js +0 -1
  51. package/lib/node/types/options.js +0 -1
  52. package/lib/node/util.js +0 -1
  53. package/lib/node-to-crud/NodeCrud.js +20 -52
  54. package/lib/node-to-crud/index.js +0 -1
  55. package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.js +21 -43
  56. package/lib/node-to-fsa/NodeFileSystemFileHandle.js +0 -1
  57. package/lib/node-to-fsa/NodeFileSystemHandle.js +0 -1
  58. package/lib/node-to-fsa/NodeFileSystemSyncAccessHandle.js +2 -5
  59. package/lib/node-to-fsa/NodeFileSystemWritableFileStream.js +0 -1
  60. package/lib/node-to-fsa/NodePermissionStatus.js +0 -1
  61. package/lib/node-to-fsa/index.js +0 -1
  62. package/lib/node-to-fsa/types.js +0 -1
  63. package/lib/node-to-fsa/util.js +6 -2
  64. package/lib/node.js +3 -4
  65. package/lib/print/index.js +1 -3
  66. package/lib/process.js +1 -2
  67. package/lib/queueMicrotask.js +0 -1
  68. package/lib/setImmediate.js +0 -1
  69. package/lib/setTimeoutUnref.js +0 -1
  70. package/lib/snapshot/async.js +0 -1
  71. package/lib/snapshot/binary.js +0 -1
  72. package/lib/snapshot/constants.js +0 -1
  73. package/lib/snapshot/index.js +0 -1
  74. package/lib/snapshot/json.js +0 -1
  75. package/lib/snapshot/shared.js +0 -1
  76. package/lib/snapshot/sync.js +0 -1
  77. package/lib/snapshot/types.js +0 -1
  78. package/lib/thingies/Defer.js +0 -1
  79. package/lib/thingies/concurrency.js +0 -1
  80. package/lib/thingies/go.js +0 -1
  81. package/lib/thingies/index.js +0 -1
  82. package/lib/thingies/of.js +0 -1
  83. package/lib/thingies/types.js +0 -1
  84. package/lib/volume-localstorage.js +0 -1
  85. package/lib/volume.js +7 -12
  86. package/lib/webfs/index.js +0 -1
  87. package/package.json +1 -1
  88. package/lib/Dirent.js.map +0 -1
  89. package/lib/Stats.js.map +0 -1
  90. package/lib/cas/types.js.map +0 -1
  91. package/lib/constants.js.map +0 -1
  92. package/lib/consts/AMODE.js.map +0 -1
  93. package/lib/consts/FLAG.js.map +0 -1
  94. package/lib/crud/types.js.map +0 -1
  95. package/lib/crud/util.js.map +0 -1
  96. package/lib/crud-to-cas/CrudCas.js.map +0 -1
  97. package/lib/crud-to-cas/CrudCasBase.js.map +0 -1
  98. package/lib/crud-to-cas/index.js.map +0 -1
  99. package/lib/crud-to-cas/util.js.map +0 -1
  100. package/lib/encoding.js.map +0 -1
  101. package/lib/fsa/types.js.map +0 -1
  102. package/lib/fsa-to-crud/FsaCrud.js.map +0 -1
  103. package/lib/fsa-to-crud/index.js.map +0 -1
  104. package/lib/fsa-to-crud/util.js.map +0 -1
  105. package/lib/fsa-to-node/FsaNodeCore.js.map +0 -1
  106. package/lib/fsa-to-node/FsaNodeDirent.js.map +0 -1
  107. package/lib/fsa-to-node/FsaNodeFs.js.map +0 -1
  108. package/lib/fsa-to-node/FsaNodeFsOpenFile.js.map +0 -1
  109. package/lib/fsa-to-node/FsaNodeReadStream.js.map +0 -1
  110. package/lib/fsa-to-node/FsaNodeStats.js.map +0 -1
  111. package/lib/fsa-to-node/FsaNodeWriteStream.js.map +0 -1
  112. package/lib/fsa-to-node/constants.js.map +0 -1
  113. package/lib/fsa-to-node/index.js.map +0 -1
  114. package/lib/fsa-to-node/json.js.map +0 -1
  115. package/lib/fsa-to-node/types.js.map +0 -1
  116. package/lib/fsa-to-node/util.js.map +0 -1
  117. package/lib/fsa-to-node/worker/FsaNodeSyncAdapterWorker.js.map +0 -1
  118. package/lib/fsa-to-node/worker/FsaNodeSyncWorker.js.map +0 -1
  119. package/lib/fsa-to-node/worker/SyncMessenger.js.map +0 -1
  120. package/lib/fsa-to-node/worker/constants.js.map +0 -1
  121. package/lib/fsa-to-node/worker/types.js.map +0 -1
  122. package/lib/index.js.map +0 -1
  123. package/lib/internal/buffer.js.map +0 -1
  124. package/lib/internal/errors.js.map +0 -1
  125. package/lib/node/FileHandle.js.map +0 -1
  126. package/lib/node/FsPromises.js.map +0 -1
  127. package/lib/node/constants.js.map +0 -1
  128. package/lib/node/lists/fsCallbackApiList.js.map +0 -1
  129. package/lib/node/lists/fsCommonObjectsList.js.map +0 -1
  130. package/lib/node/lists/fsSynchronousApiList.js.map +0 -1
  131. package/lib/node/options.js.map +0 -1
  132. package/lib/node/types/FsCallbackApi.js.map +0 -1
  133. package/lib/node/types/FsCommonObjects.js.map +0 -1
  134. package/lib/node/types/FsPromisesApi.js.map +0 -1
  135. package/lib/node/types/FsSynchronousApi.js.map +0 -1
  136. package/lib/node/types/index.js.map +0 -1
  137. package/lib/node/types/misc.js.map +0 -1
  138. package/lib/node/types/options.js.map +0 -1
  139. package/lib/node/util.js.map +0 -1
  140. package/lib/node-to-crud/NodeCrud.js.map +0 -1
  141. package/lib/node-to-crud/index.js.map +0 -1
  142. package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.js.map +0 -1
  143. package/lib/node-to-fsa/NodeFileSystemFileHandle.js.map +0 -1
  144. package/lib/node-to-fsa/NodeFileSystemHandle.js.map +0 -1
  145. package/lib/node-to-fsa/NodeFileSystemSyncAccessHandle.js.map +0 -1
  146. package/lib/node-to-fsa/NodeFileSystemWritableFileStream.js.map +0 -1
  147. package/lib/node-to-fsa/NodePermissionStatus.js.map +0 -1
  148. package/lib/node-to-fsa/index.js.map +0 -1
  149. package/lib/node-to-fsa/types.js.map +0 -1
  150. package/lib/node-to-fsa/util.js.map +0 -1
  151. package/lib/node.js.map +0 -1
  152. package/lib/print/index.js.map +0 -1
  153. package/lib/process.js.map +0 -1
  154. package/lib/queueMicrotask.js.map +0 -1
  155. package/lib/setImmediate.js.map +0 -1
  156. package/lib/setTimeoutUnref.js.map +0 -1
  157. package/lib/snapshot/async.js.map +0 -1
  158. package/lib/snapshot/binary.js.map +0 -1
  159. package/lib/snapshot/constants.js.map +0 -1
  160. package/lib/snapshot/index.js.map +0 -1
  161. package/lib/snapshot/json.js.map +0 -1
  162. package/lib/snapshot/shared.js.map +0 -1
  163. package/lib/snapshot/sync.js.map +0 -1
  164. package/lib/snapshot/types.js.map +0 -1
  165. package/lib/thingies/Defer.js.map +0 -1
  166. package/lib/thingies/concurrency.js.map +0 -1
  167. package/lib/thingies/go.js.map +0 -1
  168. package/lib/thingies/index.js.map +0 -1
  169. package/lib/thingies/of.js.map +0 -1
  170. package/lib/thingies/types.js.map +0 -1
  171. package/lib/volume-localstorage.js.map +0 -1
  172. package/lib/volume.js.map +0 -1
  173. package/lib/webfs/index.js.map +0 -1
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=FsCommonObjects.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=FsPromisesApi.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=FsSynchronousApi.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=index.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=misc.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=options.js.map
package/lib/node/util.js CHANGED
@@ -310,4 +310,3 @@ const unixify = (filepath, stripTrailing = true) => {
310
310
  return filepath;
311
311
  };
312
312
  exports.unixify = unixify;
313
- //# sourceMappingURL=util.js.map
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NodeCrud = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const util_1 = require("../node-to-fsa/util");
6
5
  const util_2 = require("../crud/util");
7
6
  const util_3 = require("../fsa-to-crud/util");
8
7
  class NodeCrud {
9
8
  constructor(options) {
10
- var _a;
11
9
  this.options = options;
12
10
  this.put = async (collection, id, data, options) => {
13
11
  (0, util_2.assertType)(collection, 'put', 'crudfs');
@@ -17,7 +15,7 @@ class NodeCrud {
17
15
  if (dir.length > 1)
18
16
  await fs.mkdir(dir, { recursive: true });
19
17
  const filename = dir + id;
20
- switch (options === null || options === void 0 ? void 0 : options.throwIf) {
18
+ switch (options?.throwIf) {
21
19
  case 'exists': {
22
20
  try {
23
21
  await fs.writeFile(filename, data, { flag: 64 /* FLAG.O_CREAT */ | 128 /* FLAG.O_EXCL */ });
@@ -153,58 +151,29 @@ class NodeCrud {
153
151
  throw error;
154
152
  }
155
153
  };
156
- this.scan = function (collection) {
157
- return tslib_1.__asyncGenerator(this, arguments, function* () {
158
- var _a, e_1, _b, _c;
159
- (0, util_2.assertType)(collection, 'scan', 'crudfs');
160
- const dir = yield tslib_1.__await(this.checkDir(collection));
161
- const dirents = (yield tslib_1.__await(this.fs.readdir(dir, { withFileTypes: true })));
162
- try {
163
- for (var _d = true, dirents_1 = tslib_1.__asyncValues(dirents), dirents_1_1; dirents_1_1 = yield tslib_1.__await(dirents_1.next()), _a = dirents_1_1.done, !_a; _d = true) {
164
- _c = dirents_1_1.value;
165
- _d = false;
166
- const entry = _c;
167
- if (entry.isFile()) {
168
- yield yield tslib_1.__await({
169
- type: 'resource',
170
- id: '' + entry.name,
171
- });
172
- }
173
- else if (entry.isDirectory()) {
174
- yield yield tslib_1.__await({
175
- type: 'collection',
176
- id: '' + entry.name,
177
- });
178
- }
179
- }
154
+ this.scan = async function* (collection) {
155
+ (0, util_2.assertType)(collection, 'scan', 'crudfs');
156
+ const dir = await this.checkDir(collection);
157
+ const dirents = (await this.fs.readdir(dir, { withFileTypes: true }));
158
+ for await (const entry of dirents) {
159
+ if (entry.isFile()) {
160
+ yield {
161
+ type: 'resource',
162
+ id: '' + entry.name,
163
+ };
180
164
  }
181
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
182
- finally {
183
- try {
184
- if (!_d && !_a && (_b = dirents_1.return)) yield tslib_1.__await(_b.call(dirents_1));
185
- }
186
- finally { if (e_1) throw e_1.error; }
165
+ else if (entry.isDirectory()) {
166
+ yield {
167
+ type: 'collection',
168
+ id: '' + entry.name,
169
+ };
187
170
  }
188
- });
171
+ }
189
172
  };
190
173
  this.list = async (collection) => {
191
- var _a, e_2, _b, _c;
192
174
  const entries = [];
193
- try {
194
- for (var _d = true, _e = tslib_1.__asyncValues(this.scan(collection)), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
195
- _c = _f.value;
196
- _d = false;
197
- const entry = _c;
198
- entries.push(entry);
199
- }
200
- }
201
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
202
- finally {
203
- try {
204
- if (!_d && !_a && (_b = _e.return)) await _b.call(_e);
205
- }
206
- finally { if (e_2) throw e_2.error; }
207
- }
175
+ for await (const entry of this.scan(collection))
176
+ entries.push(entry);
208
177
  return entries;
209
178
  };
210
179
  this.from = async (collection) => {
@@ -220,7 +189,7 @@ class NodeCrud {
220
189
  separator: this.separator,
221
190
  });
222
191
  };
223
- this.separator = (_a = options.separator) !== null && _a !== void 0 ? _a : '/';
192
+ this.separator = options.separator ?? '/';
224
193
  let dir = options.dir;
225
194
  const last = dir[dir.length - 1];
226
195
  if (last !== this.separator)
@@ -250,4 +219,3 @@ class NodeCrud {
250
219
  }
251
220
  }
252
221
  exports.NodeCrud = NodeCrud;
253
- //# sourceMappingURL=NodeCrud.js.map
@@ -3,4 +3,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NodeCrud = void 0;
4
4
  var NodeCrud_1 = require("./NodeCrud");
5
5
  Object.defineProperty(exports, "NodeCrud", { enumerable: true, get: function () { return NodeCrud_1.NodeCrud; } });
6
- //# sourceMappingURL=index.js.map
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NodeFileSystemDirectoryHandle = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const NodeFileSystemHandle_1 = require("./NodeFileSystemHandle");
6
5
  const util_1 = require("./util");
7
6
  const NodeFileSystemFileHandle_1 = require("./NodeFileSystemFileHandle");
@@ -21,30 +20,26 @@ class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle_1.NodeFileSyste
21
20
  *
22
21
  * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/keys
23
22
  */
24
- keys() {
25
- return tslib_1.__asyncGenerator(this, arguments, function* keys_1() {
26
- const list = yield tslib_1.__await(this.fs.promises.readdir(this.__path));
27
- for (const name of list)
28
- yield yield tslib_1.__await('' + name);
29
- });
23
+ async *keys() {
24
+ const list = await this.fs.promises.readdir(this.__path);
25
+ for (const name of list)
26
+ yield '' + name;
30
27
  }
31
28
  /**
32
29
  * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/entries
33
30
  */
34
- entries() {
35
- return tslib_1.__asyncGenerator(this, arguments, function* entries_1() {
36
- const { __path: path, fs, ctx } = this;
37
- const list = yield tslib_1.__await(fs.promises.readdir(path, { withFileTypes: true }));
38
- for (const d of list) {
39
- const dirent = d;
40
- const name = dirent.name + '';
41
- const newPath = path + name;
42
- if (dirent.isDirectory())
43
- yield yield tslib_1.__await([name, new NodeFileSystemDirectoryHandle(fs, newPath, ctx)]);
44
- else if (dirent.isFile())
45
- yield yield tslib_1.__await([name, new NodeFileSystemFileHandle_1.NodeFileSystemFileHandle(fs, newPath, ctx)]);
46
- }
47
- });
31
+ async *entries() {
32
+ const { __path: path, fs, ctx } = this;
33
+ const list = await fs.promises.readdir(path, { withFileTypes: true });
34
+ for (const d of list) {
35
+ const dirent = d;
36
+ const name = dirent.name + '';
37
+ const newPath = path + name;
38
+ if (dirent.isDirectory())
39
+ yield [name, new NodeFileSystemDirectoryHandle(fs, newPath, ctx)];
40
+ else if (dirent.isFile())
41
+ yield [name, new NodeFileSystemFileHandle_1.NodeFileSystemFileHandle(fs, newPath, ctx)];
42
+ }
48
43
  }
49
44
  /**
50
45
  * Returns a new array iterator containing the values for each index in the
@@ -52,25 +47,9 @@ class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle_1.NodeFileSyste
52
47
  *
53
48
  * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/values
54
49
  */
55
- values() {
56
- return tslib_1.__asyncGenerator(this, arguments, function* values_1() {
57
- var _a, e_1, _b, _c;
58
- try {
59
- for (var _d = true, _e = tslib_1.__asyncValues(this.entries()), _f; _f = yield tslib_1.__await(_e.next()), _a = _f.done, !_a; _d = true) {
60
- _c = _f.value;
61
- _d = false;
62
- const [, value] = _c;
63
- yield yield tslib_1.__await(value);
64
- }
65
- }
66
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
67
- finally {
68
- try {
69
- if (!_d && !_a && (_b = _e.return)) yield tslib_1.__await(_b.call(_e));
70
- }
71
- finally { if (e_1) throw e_1.error; }
72
- }
73
- });
50
+ async *values() {
51
+ for await (const [, value] of this.entries())
52
+ yield value;
74
53
  }
75
54
  /**
76
55
  * Returns a {@link NodeFileSystemDirectoryHandle} for a subdirectory with the specified
@@ -97,7 +76,7 @@ class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle_1.NodeFileSyste
97
76
  if (error && typeof error === 'object') {
98
77
  switch (error.code) {
99
78
  case 'ENOENT': {
100
- if (options === null || options === void 0 ? void 0 : options.create) {
79
+ if (options?.create) {
101
80
  (0, util_1.assertCanWrite)(this.ctx.mode);
102
81
  await this.fs.promises.mkdir(filename);
103
82
  return new NodeFileSystemDirectoryHandle(this.fs, filename, this.ctx);
@@ -136,7 +115,7 @@ class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle_1.NodeFileSyste
136
115
  if (error && typeof error === 'object') {
137
116
  switch (error.code) {
138
117
  case 'ENOENT': {
139
- if (options === null || options === void 0 ? void 0 : options.create) {
118
+ if (options?.create) {
140
119
  (0, util_1.assertCanWrite)(this.ctx.mode);
141
120
  await this.fs.promises.writeFile(filename, '');
142
121
  return new NodeFileSystemFileHandle_1.NodeFileSystemFileHandle(this.fs, filename, this.ctx);
@@ -222,4 +201,3 @@ class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle_1.NodeFileSyste
222
201
  }
223
202
  }
224
203
  exports.NodeFileSystemDirectoryHandle = NodeFileSystemDirectoryHandle;
225
- //# sourceMappingURL=NodeFileSystemDirectoryHandle.js.map
@@ -59,4 +59,3 @@ class NodeFileSystemFileHandle extends NodeFileSystemHandle_1.NodeFileSystemHand
59
59
  }
60
60
  }
61
61
  exports.NodeFileSystemFileHandle = NodeFileSystemFileHandle;
62
- //# sourceMappingURL=NodeFileSystemFileHandle.js.map
@@ -40,4 +40,3 @@ class NodeFileSystemHandle {
40
40
  }
41
41
  }
42
42
  exports.NodeFileSystemHandle = NodeFileSystemHandle;
43
- //# sourceMappingURL=NodeFileSystemHandle.js.map
@@ -37,10 +37,9 @@ class NodeFileSystemSyncAccessHandle {
37
37
  * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/read
38
38
  */
39
39
  async read(buffer, options = {}) {
40
- var _a;
41
40
  const buf = buffer instanceof ArrayBuffer ? buffer_1.Buffer.from(buffer) : buffer;
42
41
  try {
43
- const size = this.fs.readSync(this.fd, buf, 0, buffer.byteLength, (_a = options.at) !== null && _a !== void 0 ? _a : 0);
42
+ const size = this.fs.readSync(this.fd, buf, 0, buffer.byteLength, options.at ?? 0);
44
43
  return size;
45
44
  }
46
45
  catch (error) {
@@ -73,11 +72,10 @@ class NodeFileSystemSyncAccessHandle {
73
72
  * @param options
74
73
  */
75
74
  async write(buffer, options = {}) {
76
- var _a;
77
75
  (0, util_1.assertCanWrite)(this.ctx.mode);
78
76
  const buf = buffer instanceof ArrayBuffer ? buffer_1.Buffer.from(buffer) : buffer;
79
77
  try {
80
- return this.fs.writeSync(this.fd, buf, 0, buffer.byteLength, (_a = options.at) !== null && _a !== void 0 ? _a : 0);
78
+ return this.fs.writeSync(this.fd, buf, 0, buffer.byteLength, options.at ?? 0);
81
79
  }
82
80
  catch (error) {
83
81
  if (error instanceof DOMException)
@@ -94,4 +92,3 @@ class NodeFileSystemSyncAccessHandle {
94
92
  }
95
93
  }
96
94
  exports.NodeFileSystemSyncAccessHandle = NodeFileSystemSyncAccessHandle;
97
- //# sourceMappingURL=NodeFileSystemSyncAccessHandle.js.map
@@ -169,4 +169,3 @@ class NodeFileSystemWritableFileStream extends WritableStream {
169
169
  }
170
170
  }
171
171
  exports.NodeFileSystemWritableFileStream = NodeFileSystemWritableFileStream;
172
- //# sourceMappingURL=NodeFileSystemWritableFileStream.js.map
@@ -11,4 +11,3 @@ class NodePermissionStatus {
11
11
  }
12
12
  }
13
13
  exports.NodePermissionStatus = NodePermissionStatus;
14
- //# sourceMappingURL=NodePermissionStatus.js.map
@@ -11,4 +11,3 @@ const nodeToFsa = (fs, dirPath, ctx) => {
11
11
  return new NodeFileSystemDirectoryHandle_1.NodeFileSystemDirectoryHandle(fs, dirPath, ctx);
12
12
  };
13
13
  exports.nodeToFsa = nodeToFsa;
14
- //# sourceMappingURL=index.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -5,7 +5,12 @@ exports.newNotAllowedError = exports.newTypeMismatchError = exports.newNotFoundE
5
5
  * Creates a new {@link NodeFsaContext}.
6
6
  */
7
7
  const ctx = (partial = {}) => {
8
- return Object.assign({ separator: '/', syncHandleAllowed: false, mode: 'read' }, partial);
8
+ return {
9
+ separator: '/',
10
+ syncHandleAllowed: false,
11
+ mode: 'read',
12
+ ...partial,
13
+ };
9
14
  };
10
15
  exports.ctx = ctx;
11
16
  const basename = (path, separator) => {
@@ -33,4 +38,3 @@ const newTypeMismatchError = () => new DOMException('The path supplied exists, b
33
38
  exports.newTypeMismatchError = newTypeMismatchError;
34
39
  const newNotAllowedError = () => new DOMException('Permission not granted.', 'NotAllowedError');
35
40
  exports.newNotAllowedError = newNotAllowedError;
36
- //# sourceMappingURL=util.js.map
package/lib/node.js CHANGED
@@ -7,8 +7,8 @@ const constants_1 = require("./constants");
7
7
  const events_1 = require("events");
8
8
  const Stats_1 = require("./Stats");
9
9
  const { S_IFMT, S_IFDIR, S_IFREG, S_IFLNK, O_APPEND } = constants_1.constants;
10
- const getuid = () => { var _a, _b; return (_b = (_a = process_1.default.getuid) === null || _a === void 0 ? void 0 : _a.call(process_1.default)) !== null && _b !== void 0 ? _b : 0; };
11
- const getgid = () => { var _a, _b; return (_b = (_a = process_1.default.getgid) === null || _a === void 0 ? void 0 : _a.call(process_1.default)) !== null && _b !== void 0 ? _b : 0; };
10
+ const getuid = () => process_1.default.getuid?.() ?? 0;
11
+ const getgid = () => process_1.default.getgid?.() ?? 0;
12
12
  exports.SEP = '/';
13
13
  /**
14
14
  * Node in a file system (like i-node, v-node).
@@ -252,7 +252,7 @@ class Link extends events_1.EventEmitter {
252
252
  if (child === '.' || child === '..') {
253
253
  continue;
254
254
  }
255
- link === null || link === void 0 ? void 0 : link.syncSteps();
255
+ link?.syncSteps();
256
256
  }
257
257
  }
258
258
  constructor(vol, parent, name) {
@@ -429,4 +429,3 @@ class File {
429
429
  }
430
430
  }
431
431
  exports.File = File;
432
- //# sourceMappingURL=node.js.map
@@ -4,13 +4,12 @@ exports.toTreeSync = void 0;
4
4
  const printTree_1 = require("sonic-forest/lib/print/printTree");
5
5
  const util_1 = require("../node-to-fsa/util");
6
6
  const toTreeSync = (fs, opts = {}) => {
7
- var _a;
8
7
  const separator = opts.separator || '/';
9
8
  let dir = opts.dir || separator;
10
9
  if (dir[dir.length - 1] !== separator)
11
10
  dir += separator;
12
11
  const tab = opts.tab || '';
13
- const depth = (_a = opts.depth) !== null && _a !== void 0 ? _a : 10;
12
+ const depth = opts.depth ?? 10;
14
13
  let subtree = ' (...)';
15
14
  if (depth > 0) {
16
15
  const list = fs.readdirSync(dir, { withFileTypes: true });
@@ -30,4 +29,3 @@ const toTreeSync = (fs, opts = {}) => {
30
29
  return base + subtree;
31
30
  };
32
31
  exports.toTreeSync = toTreeSync;
33
- //# sourceMappingURL=index.js.map
package/lib/process.js CHANGED
@@ -19,7 +19,7 @@ const maybeReturnProcess = () => {
19
19
  try {
20
20
  return require('process');
21
21
  }
22
- catch (_a) {
22
+ catch {
23
23
  return undefined;
24
24
  }
25
25
  };
@@ -38,4 +38,3 @@ function createProcess() {
38
38
  }
39
39
  exports.createProcess = createProcess;
40
40
  exports.default = createProcess();
41
- //# sourceMappingURL=process.js.map
@@ -3,4 +3,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = typeof queueMicrotask === 'function' ? queueMicrotask : (cb => Promise.resolve()
4
4
  .then(() => cb())
5
5
  .catch(() => { }));
6
- //# sourceMappingURL=queueMicrotask.js.map
@@ -6,4 +6,3 @@ if (typeof setImmediate === 'function')
6
6
  else
7
7
  _setImmediate = setTimeout.bind(typeof globalThis !== 'undefined' ? globalThis : global);
8
8
  exports.default = _setImmediate;
9
- //# sourceMappingURL=setImmediate.js.map
@@ -11,4 +11,3 @@ function setTimeoutUnref(callback, time, args) {
11
11
  return ref;
12
12
  }
13
13
  exports.default = setTimeoutUnref;
14
- //# sourceMappingURL=setTimeoutUnref.js.map
@@ -56,4 +56,3 @@ const fromSnapshot = async (snapshot, { fs, path = '/', separator = '/' }) => {
56
56
  }
57
57
  };
58
58
  exports.fromSnapshot = fromSnapshot;
59
- //# sourceMappingURL=async.js.map
@@ -28,4 +28,3 @@ const fromBinarySnapshot = async (uint8, options) => {
28
28
  await (0, async_1.fromSnapshot)(snapshot, options);
29
29
  };
30
30
  exports.fromBinarySnapshot = fromBinarySnapshot;
31
- //# sourceMappingURL=binary.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=constants.js.map
@@ -5,4 +5,3 @@ tslib_1.__exportStar(require("./constants"), exports);
5
5
  tslib_1.__exportStar(require("./sync"), exports);
6
6
  tslib_1.__exportStar(require("./binary"), exports);
7
7
  tslib_1.__exportStar(require("./json"), exports);
8
- //# sourceMappingURL=index.js.map
@@ -28,4 +28,3 @@ const fromJsonSnapshot = async (uint8, options) => {
28
28
  await (0, async_1.fromSnapshot)(snapshot, options);
29
29
  };
30
30
  exports.fromJsonSnapshot = fromJsonSnapshot;
31
- //# sourceMappingURL=json.js.map
@@ -3,4 +3,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.writer = void 0;
4
4
  const Writer_1 = require("@jsonjoy.com/util/lib/buffers/Writer");
5
5
  exports.writer = new Writer_1.Writer(1024 * 32);
6
- //# sourceMappingURL=shared.js.map
@@ -56,4 +56,3 @@ const fromSnapshotSync = (snapshot, { fs, path = '/', separator = '/' }) => {
56
56
  }
57
57
  };
58
58
  exports.fromSnapshotSync = fromSnapshotSync;
59
- //# sourceMappingURL=sync.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -22,4 +22,3 @@ class Defer {
22
22
  }
23
23
  }
24
24
  exports.Defer = Defer;
25
- //# sourceMappingURL=Defer.js.map
@@ -39,4 +39,3 @@ const concurrency = (limit) => {
39
39
  };
40
40
  };
41
41
  exports.concurrency = concurrency;
42
- //# sourceMappingURL=concurrency.js.map
@@ -6,4 +6,3 @@ const go = (code) => {
6
6
  code().catch(() => { });
7
7
  };
8
8
  exports.go = go;
9
- //# sourceMappingURL=go.js.map
@@ -5,4 +5,3 @@ tslib_1.__exportStar(require("./concurrency"), exports);
5
5
  tslib_1.__exportStar(require("./Defer"), exports);
6
6
  tslib_1.__exportStar(require("./go"), exports);
7
7
  tslib_1.__exportStar(require("./of"), exports);
8
- //# sourceMappingURL=index.js.map
@@ -19,4 +19,3 @@ const of = async (promise) => {
19
19
  }
20
20
  };
21
21
  exports.of = of;
22
- //# sourceMappingURL=of.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -71,4 +71,3 @@ function createVolume(namespace, LS = localStorage) {
71
71
  };
72
72
  }
73
73
  exports.createVolume = createVolume;
74
- //# sourceMappingURL=volume-localstorage.js.map
package/lib/volume.js CHANGED
@@ -597,7 +597,7 @@ class Volume {
597
597
  }
598
598
  readvBase(fd, buffers, position) {
599
599
  const file = this.getFileByFdOrThrow(fd);
600
- let p = position !== null && position !== void 0 ? position : undefined;
600
+ let p = position ?? undefined;
601
601
  if (p === -1) {
602
602
  p = undefined;
603
603
  }
@@ -701,7 +701,7 @@ class Volume {
701
701
  }
702
702
  writevBase(fd, buffers, position) {
703
703
  const file = this.getFileByFdOrThrow(fd);
704
- let p = position !== null && position !== void 0 ? position : undefined;
704
+ let p = position ?? undefined;
705
705
  if (p === -1) {
706
706
  p = undefined;
707
707
  }
@@ -1077,7 +1077,7 @@ class Volume {
1077
1077
  list.push(Dirent_1.default.build(child, options.encoding));
1078
1078
  // recursion
1079
1079
  if (options.recursive && child.children.size) {
1080
- const recurseOptions = Object.assign(Object.assign({}, options), { recursive: true, withFileTypes: true });
1080
+ const recurseOptions = { ...options, recursive: true, withFileTypes: true };
1081
1081
  const childList = this.readdirBase(child.getPath(), recurseOptions);
1082
1082
  list.push(...childList);
1083
1083
  }
@@ -1695,7 +1695,6 @@ FsReadStream.prototype._destroy = function (err, cb) {
1695
1695
  });
1696
1696
  };
1697
1697
  FsReadStream.prototype.close = function (cb) {
1698
- var _a;
1699
1698
  if (cb)
1700
1699
  this.once('close', cb);
1701
1700
  if (this.closed || typeof this.fd !== 'number') {
@@ -1708,7 +1707,7 @@ FsReadStream.prototype.close = function (cb) {
1708
1707
  // Since Node 18, there is only a getter for '.closed'.
1709
1708
  // The first branch mimics other setters from Readable.
1710
1709
  // See https://github.com/nodejs/node/blob/v18.0.0/lib/internal/streams/readable.js#L1243
1711
- if (typeof ((_a = this._readableState) === null || _a === void 0 ? void 0 : _a.closed) === 'boolean') {
1710
+ if (typeof this._readableState?.closed === 'boolean') {
1712
1711
  this._readableState.closed = true;
1713
1712
  }
1714
1713
  else {
@@ -1829,7 +1828,6 @@ FsWriteStream.prototype._writev = function (data, cb) {
1829
1828
  this.pos += size;
1830
1829
  };
1831
1830
  FsWriteStream.prototype.close = function (cb) {
1832
- var _a;
1833
1831
  if (cb)
1834
1832
  this.once('close', cb);
1835
1833
  if (this.closed || typeof this.fd !== 'number') {
@@ -1842,7 +1840,7 @@ FsWriteStream.prototype.close = function (cb) {
1842
1840
  // Since Node 18, there is only a getter for '.closed'.
1843
1841
  // The first branch mimics other setters from Writable.
1844
1842
  // See https://github.com/nodejs/node/blob/v18.0.0/lib/internal/streams/writable.js#L766
1845
- if (typeof ((_a = this._writableState) === null || _a === void 0 ? void 0 : _a.closed) === 'boolean') {
1843
+ if (typeof this._writableState?.closed === 'boolean') {
1846
1844
  this._writableState.closed = true;
1847
1845
  }
1848
1846
  else {
@@ -1916,7 +1914,6 @@ class FSWatcher extends events_1.EventEmitter {
1916
1914
  throw error;
1917
1915
  }
1918
1916
  const watchLinkNodeChanged = (link) => {
1919
- var _a;
1920
1917
  const filepath = link.getPath();
1921
1918
  const node = link.getNode();
1922
1919
  const onNodeChange = () => {
@@ -1927,12 +1924,11 @@ class FSWatcher extends events_1.EventEmitter {
1927
1924
  return this.emit('change', 'change', filename);
1928
1925
  };
1929
1926
  node.on('change', onNodeChange);
1930
- const removers = (_a = this._listenerRemovers.get(node.ino)) !== null && _a !== void 0 ? _a : [];
1927
+ const removers = this._listenerRemovers.get(node.ino) ?? [];
1931
1928
  removers.push(() => node.removeListener('change', onNodeChange));
1932
1929
  this._listenerRemovers.set(node.ino, removers);
1933
1930
  };
1934
1931
  const watchLinkChildrenChanged = (link) => {
1935
- var _a;
1936
1932
  const node = link.getNode();
1937
1933
  // when a new link added
1938
1934
  const onLinkChildAdd = (l) => {
@@ -1972,7 +1968,7 @@ class FSWatcher extends events_1.EventEmitter {
1972
1968
  // link children add/remove
1973
1969
  link.on('child:add', onLinkChildAdd);
1974
1970
  link.on('child:delete', onLinkChildDelete);
1975
- const removers = (_a = this._listenerRemovers.get(node.ino)) !== null && _a !== void 0 ? _a : [];
1971
+ const removers = this._listenerRemovers.get(node.ino) ?? [];
1976
1972
  removers.push(() => {
1977
1973
  link.removeListener('child:add', onLinkChildAdd);
1978
1974
  link.removeListener('child:delete', onLinkChildDelete);
@@ -2010,4 +2006,3 @@ class FSWatcher extends events_1.EventEmitter {
2010
2006
  }
2011
2007
  }
2012
2008
  exports.FSWatcher = FSWatcher;
2013
- //# sourceMappingURL=volume.js.map
@@ -19,4 +19,3 @@ else {
19
19
  const worker = new FsaNodeSyncWorker_1.FsaNodeSyncWorker();
20
20
  worker.start();
21
21
  }
22
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memfs",
3
- "version": "4.9.1",
3
+ "version": "5.0.0-next.1",
4
4
  "description": "In-memory file-system with Node's fs API.",
5
5
  "keywords": [
6
6
  "fs",
package/lib/Dirent.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"Dirent.js","sourceRoot":"","sources":["../src/Dirent.ts"],"names":[],"mappings":";;;AACA,2CAAwC;AACxC,yCAAwE;AAGxE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,qBAAS,CAAC;AAE7F;;GAEG;AACH,MAAa,MAAM;IAAnB;QAYE,SAAI,GAAa,EAAE,CAAC;QACpB,SAAI,GAAG,EAAE,CAAC;QACF,SAAI,GAAW,CAAC,CAAC;IAiC3B,CAAC;IA9CC,MAAM,CAAC,KAAK,CAAC,IAAU,EAAE,QAAuC;QAC9D,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QAC5B,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAEhC,MAAM,CAAC,IAAI,GAAG,IAAA,wBAAa,EAAC,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;QACtD,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAEnC,OAAO,MAAM,CAAC;IAChB,CAAC;IAMO,kBAAkB,CAAC,QAAgB;QACzC,OAAO,CAAC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,QAAQ,CAAC;IAC3C,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;CACF;AA/CD,wBA+CC;AAED,kBAAe,MAAM,CAAC"}