memfs 4.1.0 → 4.2.0

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 (254) hide show
  1. package/README.md +10 -7
  2. package/demo/runkit.js +5 -0
  3. package/lib/Dirent.js +1 -0
  4. package/lib/Dirent.js.map +1 -0
  5. package/lib/Stats.js +2 -2
  6. package/lib/Stats.js.map +1 -0
  7. package/lib/__tests__/util.js +1 -0
  8. package/lib/__tests__/util.js.map +1 -0
  9. package/lib/cas/types.d.ts +10 -0
  10. package/lib/{node/types/callback.js → cas/types.js} +1 -0
  11. package/lib/cas/types.js.map +1 -0
  12. package/lib/constants.js +1 -0
  13. package/lib/constants.js.map +1 -0
  14. package/lib/consts/AMODE.js +1 -0
  15. package/lib/consts/AMODE.js.map +1 -0
  16. package/lib/consts/FLAG.d.ts +6 -0
  17. package/lib/consts/FLAG.js +1 -0
  18. package/lib/consts/FLAG.js.map +1 -0
  19. package/lib/crud/__tests__/matryoshka.test.d.ts +1 -0
  20. package/lib/crud/__tests__/matryoshka.test.js +69 -0
  21. package/lib/crud/__tests__/matryoshka.test.js.map +1 -0
  22. package/lib/crud/__tests__/testCrudfs.d.ts +6 -0
  23. package/lib/crud/__tests__/testCrudfs.js +278 -0
  24. package/lib/crud/__tests__/testCrudfs.js.map +1 -0
  25. package/lib/crud/types.d.ts +80 -0
  26. package/lib/{node/types/promises.js → crud/types.js} +1 -0
  27. package/lib/crud/types.js.map +1 -0
  28. package/lib/crud/util.d.ts +2 -0
  29. package/lib/crud/util.js +11 -0
  30. package/lib/crud/util.js.map +1 -0
  31. package/lib/crud-to-cas/CrudCas.d.ts +14 -0
  32. package/lib/crud-to-cas/CrudCas.js +57 -0
  33. package/lib/crud-to-cas/CrudCas.js.map +1 -0
  34. package/lib/crud-to-cas/__tests__/CrudCas.test.d.ts +1 -0
  35. package/lib/crud-to-cas/__tests__/CrudCas.test.js +38 -0
  36. package/lib/crud-to-cas/__tests__/CrudCas.test.js.map +1 -0
  37. package/lib/crud-to-cas/__tests__/testCasfs.d.ts +9 -0
  38. package/lib/crud-to-cas/__tests__/testCasfs.js +108 -0
  39. package/lib/crud-to-cas/__tests__/testCasfs.js.map +1 -0
  40. package/lib/crud-to-cas/index.d.ts +1 -0
  41. package/lib/crud-to-cas/index.js +6 -0
  42. package/lib/crud-to-cas/index.js.map +1 -0
  43. package/lib/crud-to-cas/util.d.ts +2 -0
  44. package/lib/crud-to-cas/util.js +13 -0
  45. package/lib/crud-to-cas/util.js.map +1 -0
  46. package/lib/encoding.js +1 -0
  47. package/lib/encoding.js.map +1 -0
  48. package/lib/fsa/types.js +1 -0
  49. package/lib/fsa/types.js.map +1 -0
  50. package/lib/fsa-to-crud/FsaCrud.d.ts +15 -0
  51. package/lib/fsa-to-crud/FsaCrud.js +191 -0
  52. package/lib/fsa-to-crud/FsaCrud.js.map +1 -0
  53. package/lib/fsa-to-crud/__tests__/FsaCrud.test.d.ts +1 -0
  54. package/lib/fsa-to-crud/__tests__/FsaCrud.test.js +17 -0
  55. package/lib/fsa-to-crud/__tests__/FsaCrud.test.js.map +1 -0
  56. package/lib/fsa-to-crud/index.d.ts +1 -0
  57. package/lib/fsa-to-crud/index.js +6 -0
  58. package/lib/fsa-to-crud/index.js.map +1 -0
  59. package/lib/fsa-to-crud/util.d.ts +5 -0
  60. package/lib/fsa-to-crud/util.js +12 -0
  61. package/lib/fsa-to-crud/util.js.map +1 -0
  62. package/lib/fsa-to-node/FsaNodeCore.d.ts +3 -2
  63. package/lib/fsa-to-node/FsaNodeCore.js +109 -87
  64. package/lib/fsa-to-node/FsaNodeCore.js.map +1 -0
  65. package/lib/fsa-to-node/FsaNodeDirent.js +1 -0
  66. package/lib/fsa-to-node/FsaNodeDirent.js.map +1 -0
  67. package/lib/fsa-to-node/FsaNodeFs.d.ts +14 -2
  68. package/lib/fsa-to-node/FsaNodeFs.js +156 -143
  69. package/lib/fsa-to-node/FsaNodeFs.js.map +1 -0
  70. package/lib/fsa-to-node/FsaNodeFsOpenFile.js +13 -25
  71. package/lib/fsa-to-node/FsaNodeFsOpenFile.js.map +1 -0
  72. package/lib/fsa-to-node/FsaNodeReadStream.js +14 -24
  73. package/lib/fsa-to-node/FsaNodeReadStream.js.map +1 -0
  74. package/lib/fsa-to-node/FsaNodeStats.js +1 -0
  75. package/lib/fsa-to-node/FsaNodeStats.js.map +1 -0
  76. package/lib/fsa-to-node/FsaNodeWriteStream.js +35 -47
  77. package/lib/fsa-to-node/FsaNodeWriteStream.js.map +1 -0
  78. package/lib/fsa-to-node/__tests__/FsaNodeFs.test.js +357 -348
  79. package/lib/fsa-to-node/__tests__/FsaNodeFs.test.js.map +1 -0
  80. package/lib/fsa-to-node/__tests__/util.test.js +4 -0
  81. package/lib/fsa-to-node/__tests__/util.test.js.map +1 -0
  82. package/lib/fsa-to-node/constants.js +1 -0
  83. package/lib/fsa-to-node/constants.js.map +1 -0
  84. package/lib/fsa-to-node/index.js +1 -0
  85. package/lib/fsa-to-node/index.js.map +1 -0
  86. package/lib/fsa-to-node/json.js +1 -0
  87. package/lib/fsa-to-node/json.js.map +1 -0
  88. package/lib/fsa-to-node/types.js +1 -0
  89. package/lib/fsa-to-node/types.js.map +1 -0
  90. package/lib/fsa-to-node/util.js +7 -13
  91. package/lib/fsa-to-node/util.js.map +1 -0
  92. package/lib/fsa-to-node/worker/FsaNodeSyncAdapterWorker.js +31 -41
  93. package/lib/fsa-to-node/worker/FsaNodeSyncAdapterWorker.js.map +1 -0
  94. package/lib/fsa-to-node/worker/FsaNodeSyncWorker.js +91 -105
  95. package/lib/fsa-to-node/worker/FsaNodeSyncWorker.js.map +1 -0
  96. package/lib/fsa-to-node/worker/SyncMessenger.js +4 -12
  97. package/lib/fsa-to-node/worker/SyncMessenger.js.map +1 -0
  98. package/lib/fsa-to-node/worker/constants.js +1 -0
  99. package/lib/fsa-to-node/worker/constants.js.map +1 -0
  100. package/lib/fsa-to-node/worker/types.js +1 -0
  101. package/lib/fsa-to-node/worker/types.js.map +1 -0
  102. package/lib/index.d.ts +4 -1
  103. package/lib/index.js +8 -6
  104. package/lib/index.js.map +1 -0
  105. package/lib/internal/buffer.js +1 -0
  106. package/lib/internal/buffer.js.map +1 -0
  107. package/lib/internal/errors.js +1 -0
  108. package/lib/internal/errors.js.map +1 -0
  109. package/lib/node/FileHandle.js +1 -0
  110. package/lib/node/FileHandle.js.map +1 -0
  111. package/lib/node/FsPromises.d.ts +86 -0
  112. package/lib/node/FsPromises.js +54 -0
  113. package/lib/node/FsPromises.js.map +1 -0
  114. package/lib/node/constants.js +2 -1
  115. package/lib/node/constants.js.map +1 -0
  116. package/lib/node/lists/fsCallbackApiList.d.ts +2 -0
  117. package/lib/node/lists/fsCallbackApiList.js +47 -0
  118. package/lib/node/lists/fsCallbackApiList.js.map +1 -0
  119. package/lib/node/lists/fsCommonObjectsList.d.ts +2 -0
  120. package/lib/node/lists/fsCommonObjectsList.js +19 -0
  121. package/lib/node/lists/fsCommonObjectsList.js.map +1 -0
  122. package/lib/node/lists/fsSynchronousApiList.d.ts +2 -0
  123. package/lib/node/lists/fsSynchronousApiList.js +46 -0
  124. package/lib/node/lists/fsSynchronousApiList.js.map +1 -0
  125. package/lib/node/options.js +1 -0
  126. package/lib/node/options.js.map +1 -0
  127. package/lib/node/types/{callback.d.ts → FsCallbackApi.d.ts} +49 -40
  128. package/lib/node/types/FsCallbackApi.js +3 -0
  129. package/lib/node/types/FsCallbackApi.js.map +1 -0
  130. package/lib/node/types/FsCommonObjects.d.ts +4 -4
  131. package/lib/node/types/FsCommonObjects.js +1 -0
  132. package/lib/node/types/FsCommonObjects.js.map +1 -0
  133. package/lib/node/types/{promises.d.ts → FsPromisesApi.d.ts} +11 -0
  134. package/lib/node/types/FsPromisesApi.js +3 -0
  135. package/lib/node/types/FsPromisesApi.js.map +1 -0
  136. package/lib/node/types/FsSynchronousApi.d.ts +64 -58
  137. package/lib/node/types/FsSynchronousApi.js +1 -0
  138. package/lib/node/types/FsSynchronousApi.js.map +1 -0
  139. package/lib/node/types/index.d.ts +2 -2
  140. package/lib/node/types/index.js +1 -0
  141. package/lib/node/types/index.js.map +1 -0
  142. package/lib/node/types/misc.d.ts +20 -0
  143. package/lib/node/types/misc.js +1 -0
  144. package/lib/node/types/misc.js.map +1 -0
  145. package/lib/node/types/options.d.ts +62 -0
  146. package/lib/node/types/options.js +1 -0
  147. package/lib/node/types/options.js.map +1 -0
  148. package/lib/node/util.d.ts +2 -1
  149. package/lib/node/util.js +30 -1
  150. package/lib/node/util.js.map +1 -0
  151. package/lib/node-to-crud/NodeCrud.d.ts +22 -0
  152. package/lib/node-to-crud/NodeCrud.js +233 -0
  153. package/lib/node-to-crud/NodeCrud.js.map +1 -0
  154. package/lib/node-to-crud/__tests__/FsaCrud.test.d.ts +1 -0
  155. package/lib/node-to-crud/__tests__/FsaCrud.test.js +18 -0
  156. package/lib/node-to-crud/__tests__/FsaCrud.test.js.map +1 -0
  157. package/lib/node-to-crud/index.d.ts +1 -0
  158. package/lib/node-to-crud/index.js +6 -0
  159. package/lib/node-to-crud/index.js.map +1 -0
  160. package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.d.ts +3 -2
  161. package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.js +112 -151
  162. package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.js.map +1 -0
  163. package/lib/node-to-fsa/NodeFileSystemFileHandle.js +25 -36
  164. package/lib/node-to-fsa/NodeFileSystemFileHandle.js.map +1 -0
  165. package/lib/node-to-fsa/NodeFileSystemHandle.js +3 -13
  166. package/lib/node-to-fsa/NodeFileSystemHandle.js.map +1 -0
  167. package/lib/node-to-fsa/NodeFileSystemSyncAccessHandle.js +42 -62
  168. package/lib/node-to-fsa/NodeFileSystemSyncAccessHandle.js.map +1 -0
  169. package/lib/node-to-fsa/NodeFileSystemWritableFileStream.js +92 -116
  170. package/lib/node-to-fsa/NodeFileSystemWritableFileStream.js.map +1 -0
  171. package/lib/node-to-fsa/NodePermissionStatus.js +1 -0
  172. package/lib/node-to-fsa/NodePermissionStatus.js.map +1 -0
  173. package/lib/node-to-fsa/__tests__/NodeFileSystemDirectoryHandle.test.js +175 -234
  174. package/lib/node-to-fsa/__tests__/NodeFileSystemDirectoryHandle.test.js.map +1 -0
  175. package/lib/node-to-fsa/__tests__/NodeFileSystemFileHandle.test.js +91 -99
  176. package/lib/node-to-fsa/__tests__/NodeFileSystemFileHandle.test.js.map +1 -0
  177. package/lib/node-to-fsa/__tests__/NodeFileSystemHandle.test.js +10 -18
  178. package/lib/node-to-fsa/__tests__/NodeFileSystemHandle.test.js.map +1 -0
  179. package/lib/node-to-fsa/__tests__/NodeFileSystemSyncAccessHandle.test.js +70 -78
  180. package/lib/node-to-fsa/__tests__/NodeFileSystemSyncAccessHandle.test.js.map +1 -0
  181. package/lib/node-to-fsa/__tests__/NodeFileSystemWritableFileStream.test.js +31 -39
  182. package/lib/node-to-fsa/__tests__/NodeFileSystemWritableFileStream.test.js.map +1 -0
  183. package/lib/node-to-fsa/__tests__/scenarios.test.js +18 -26
  184. package/lib/node-to-fsa/__tests__/scenarios.test.js.map +1 -0
  185. package/lib/node-to-fsa/__tests__/util.test.js +5 -0
  186. package/lib/node-to-fsa/__tests__/util.test.js.map +1 -0
  187. package/lib/node-to-fsa/index.js +6 -18
  188. package/lib/node-to-fsa/index.js.map +1 -0
  189. package/lib/node-to-fsa/types.d.ts +5 -2
  190. package/lib/node-to-fsa/types.js +1 -0
  191. package/lib/node-to-fsa/types.js.map +1 -0
  192. package/lib/node-to-fsa/util.js +3 -0
  193. package/lib/node-to-fsa/util.js.map +1 -0
  194. package/lib/node.js +1 -0
  195. package/lib/node.js.map +1 -0
  196. package/lib/print/__tests__/index.test.d.ts +1 -0
  197. package/lib/print/__tests__/index.test.js +77 -0
  198. package/lib/print/__tests__/index.test.js.map +1 -0
  199. package/lib/print/index.d.ts +8 -0
  200. package/lib/print/index.js +33 -0
  201. package/lib/print/index.js.map +1 -0
  202. package/lib/process.js +1 -0
  203. package/lib/process.js.map +1 -0
  204. package/lib/setImmediate.js +1 -0
  205. package/lib/setImmediate.js.map +1 -0
  206. package/lib/setTimeoutUnref.js +1 -0
  207. package/lib/setTimeoutUnref.js.map +1 -0
  208. package/lib/snapshot/__tests__/async.test.d.ts +1 -0
  209. package/lib/snapshot/__tests__/async.test.js +63 -0
  210. package/lib/snapshot/__tests__/async.test.js.map +1 -0
  211. package/lib/snapshot/__tests__/binary.test.d.ts +1 -0
  212. package/lib/snapshot/__tests__/binary.test.js +59 -0
  213. package/lib/snapshot/__tests__/binary.test.js.map +1 -0
  214. package/lib/snapshot/__tests__/json.test.d.ts +1 -0
  215. package/lib/snapshot/__tests__/json.test.js +68 -0
  216. package/lib/snapshot/__tests__/json.test.js.map +1 -0
  217. package/lib/snapshot/__tests__/sync.test.d.ts +1 -0
  218. package/lib/snapshot/__tests__/sync.test.js +63 -0
  219. package/lib/snapshot/__tests__/sync.test.js.map +1 -0
  220. package/lib/snapshot/async.d.ts +3 -0
  221. package/lib/snapshot/async.js +59 -0
  222. package/lib/snapshot/async.js.map +1 -0
  223. package/lib/snapshot/binary.d.ts +6 -0
  224. package/lib/snapshot/binary.js +31 -0
  225. package/lib/snapshot/binary.js.map +1 -0
  226. package/lib/snapshot/constants.d.ts +5 -0
  227. package/lib/snapshot/constants.js +3 -0
  228. package/lib/snapshot/constants.js.map +1 -0
  229. package/lib/snapshot/index.d.ts +5 -0
  230. package/lib/snapshot/index.js +8 -0
  231. package/lib/snapshot/index.js.map +1 -0
  232. package/lib/snapshot/json.d.ts +10 -0
  233. package/lib/snapshot/json.js +31 -0
  234. package/lib/snapshot/json.js.map +1 -0
  235. package/lib/snapshot/shared.d.ts +2 -0
  236. package/lib/snapshot/shared.js +6 -0
  237. package/lib/snapshot/shared.js.map +1 -0
  238. package/lib/snapshot/sync.d.ts +3 -0
  239. package/lib/snapshot/sync.js +59 -0
  240. package/lib/snapshot/sync.js.map +1 -0
  241. package/lib/snapshot/types.d.ts +30 -0
  242. package/lib/snapshot/types.js +3 -0
  243. package/lib/snapshot/types.js.map +1 -0
  244. package/lib/volume-localstorage.js +1 -0
  245. package/lib/volume-localstorage.js.map +1 -0
  246. package/lib/volume.d.ts +18 -7
  247. package/lib/volume.js +25 -16
  248. package/lib/volume.js.map +1 -0
  249. package/lib/webfs/index.js +1 -0
  250. package/lib/webfs/index.js.map +1 -0
  251. package/package.json +67 -26
  252. package/lib/getBigInt.js +0 -5
  253. package/lib/node/promises.d.ts +0 -2
  254. package/lib/node/promises.js +0 -86
@@ -1,34 +1,7 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
12
- var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
13
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
14
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
15
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
16
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
17
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
18
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
19
- function fulfill(value) { resume("next", value); }
20
- function reject(value) { resume("throw", value); }
21
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
22
- };
23
- var __asyncValues = (this && this.__asyncValues) || function (o) {
24
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
25
- var m = o[Symbol.asyncIterator], i;
26
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
27
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
28
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
29
- };
30
2
  Object.defineProperty(exports, "__esModule", { value: true });
31
3
  exports.NodeFileSystemDirectoryHandle = void 0;
4
+ const tslib_1 = require("tslib");
32
5
  const NodeFileSystemHandle_1 = require("./NodeFileSystemHandle");
33
6
  const util_1 = require("./util");
34
7
  const NodeFileSystemFileHandle_1 = require("./NodeFileSystemFileHandle");
@@ -36,11 +9,11 @@ const NodeFileSystemFileHandle_1 = require("./NodeFileSystemFileHandle");
36
9
  * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle
37
10
  */
38
11
  class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle_1.NodeFileSystemHandle {
39
- constructor(fs, __path, ctx = {}) {
40
- super('directory', (0, util_1.basename)(__path, ctx.separator || '/'));
12
+ constructor(fs, path, ctx = {}) {
13
+ super('directory', (0, util_1.basename)(path, ctx.separator || '/'));
41
14
  this.fs = fs;
42
- this.__path = __path;
43
15
  this.ctx = (0, util_1.ctx)(ctx);
16
+ this.__path = path[path.length - 1] === this.ctx.separator ? path : path + this.ctx.separator;
44
17
  }
45
18
  /**
46
19
  * Returns a new array iterator containing the keys for each item in
@@ -49,27 +22,27 @@ class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle_1.NodeFileSyste
49
22
  * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/keys
50
23
  */
51
24
  keys() {
52
- return __asyncGenerator(this, arguments, function* keys_1() {
53
- const list = yield __await(this.fs.promises.readdir(this.__path));
25
+ return tslib_1.__asyncGenerator(this, arguments, function* keys_1() {
26
+ const list = yield tslib_1.__await(this.fs.promises.readdir(this.__path));
54
27
  for (const name of list)
55
- yield yield __await('' + name);
28
+ yield yield tslib_1.__await('' + name);
56
29
  });
57
30
  }
58
31
  /**
59
32
  * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/entries
60
33
  */
61
34
  entries() {
62
- return __asyncGenerator(this, arguments, function* entries_1() {
35
+ return tslib_1.__asyncGenerator(this, arguments, function* entries_1() {
63
36
  const { __path: path, fs, ctx } = this;
64
- const list = yield __await(fs.promises.readdir(path, { withFileTypes: true }));
37
+ const list = yield tslib_1.__await(fs.promises.readdir(path, { withFileTypes: true }));
65
38
  for (const d of list) {
66
39
  const dirent = d;
67
40
  const name = dirent.name + '';
68
41
  const newPath = path + ctx.separator + name;
69
42
  if (dirent.isDirectory())
70
- yield yield __await([name, new NodeFileSystemDirectoryHandle(fs, newPath, ctx)]);
43
+ yield yield tslib_1.__await([name, new NodeFileSystemDirectoryHandle(fs, newPath, ctx)]);
71
44
  else if (dirent.isFile())
72
- yield yield __await([name, new NodeFileSystemFileHandle_1.NodeFileSystemFileHandle(fs, name, ctx)]);
45
+ yield yield tslib_1.__await([name, new NodeFileSystemFileHandle_1.NodeFileSystemFileHandle(fs, name, ctx)]);
73
46
  }
74
47
  });
75
48
  }
@@ -80,25 +53,20 @@ class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle_1.NodeFileSyste
80
53
  * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/values
81
54
  */
82
55
  values() {
83
- return __asyncGenerator(this, arguments, function* values_1() {
56
+ return tslib_1.__asyncGenerator(this, arguments, function* values_1() {
84
57
  var _a, e_1, _b, _c;
85
58
  try {
86
- for (var _d = true, _e = __asyncValues(this.entries()), _f; _f = yield __await(_e.next()), _a = _f.done, !_a;) {
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) {
87
60
  _c = _f.value;
88
61
  _d = false;
89
- try {
90
- const [, value] = _c;
91
- yield yield __await(value);
92
- }
93
- finally {
94
- _d = true;
95
- }
62
+ const [, value] = _c;
63
+ yield yield tslib_1.__await(value);
96
64
  }
97
65
  }
98
66
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
99
67
  finally {
100
68
  try {
101
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
69
+ if (!_d && !_a && (_b = _e.return)) yield tslib_1.__await(_b.call(_e));
102
70
  }
103
71
  finally { if (e_1) throw e_1.error; }
104
72
  }
@@ -114,37 +82,35 @@ class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle_1.NodeFileSyste
114
82
  * @param options An optional object containing options for the retrieved
115
83
  * subdirectory.
116
84
  */
117
- getDirectoryHandle(name, options) {
118
- return __awaiter(this, void 0, void 0, function* () {
119
- (0, util_1.assertName)(name, 'getDirectoryHandle', 'FileSystemDirectoryHandle');
120
- const filename = this.__path + this.ctx.separator + name;
121
- try {
122
- const stats = yield this.fs.promises.stat(filename);
123
- if (!stats.isDirectory())
124
- throw (0, util_1.newTypeMismatchError)();
125
- return new NodeFileSystemDirectoryHandle(this.fs, filename, this.ctx);
126
- }
127
- catch (error) {
128
- if (error instanceof DOMException)
129
- throw error;
130
- if (error && typeof error === 'object') {
131
- switch (error.code) {
132
- case 'ENOENT': {
133
- if (options === null || options === void 0 ? void 0 : options.create) {
134
- (0, util_1.assertCanWrite)(this.ctx.mode);
135
- yield this.fs.promises.mkdir(filename);
136
- return new NodeFileSystemDirectoryHandle(this.fs, filename, this.ctx);
137
- }
138
- throw (0, util_1.newNotFoundError)();
85
+ async getDirectoryHandle(name, options) {
86
+ (0, util_1.assertName)(name, 'getDirectoryHandle', 'FileSystemDirectoryHandle');
87
+ const filename = this.__path + name;
88
+ try {
89
+ const stats = await this.fs.promises.stat(filename);
90
+ if (!stats.isDirectory())
91
+ throw (0, util_1.newTypeMismatchError)();
92
+ return new NodeFileSystemDirectoryHandle(this.fs, filename, this.ctx);
93
+ }
94
+ catch (error) {
95
+ if (error instanceof DOMException)
96
+ throw error;
97
+ if (error && typeof error === 'object') {
98
+ switch (error.code) {
99
+ case 'ENOENT': {
100
+ if (options === null || options === void 0 ? void 0 : options.create) {
101
+ (0, util_1.assertCanWrite)(this.ctx.mode);
102
+ await this.fs.promises.mkdir(filename);
103
+ return new NodeFileSystemDirectoryHandle(this.fs, filename, this.ctx);
139
104
  }
140
- case 'EPERM':
141
- case 'EACCES':
142
- throw (0, util_1.newNotAllowedError)();
105
+ throw (0, util_1.newNotFoundError)();
143
106
  }
107
+ case 'EPERM':
108
+ case 'EACCES':
109
+ throw (0, util_1.newNotAllowedError)();
144
110
  }
145
- throw error;
146
111
  }
147
- });
112
+ throw error;
113
+ }
148
114
  }
149
115
  /**
150
116
  * Returns a {@link FileSystemFileHandle} for a file with the specified name,
@@ -155,37 +121,35 @@ class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle_1.NodeFileSyste
155
121
  * the file you wish to retrieve.
156
122
  * @param options An optional object containing options for the retrieved file.
157
123
  */
158
- getFileHandle(name, options) {
159
- return __awaiter(this, void 0, void 0, function* () {
160
- (0, util_1.assertName)(name, 'getFileHandle', 'FileSystemDirectoryHandle');
161
- const filename = this.__path + this.ctx.separator + name;
162
- try {
163
- const stats = yield this.fs.promises.stat(filename);
164
- if (!stats.isFile())
165
- throw (0, util_1.newTypeMismatchError)();
166
- return new NodeFileSystemFileHandle_1.NodeFileSystemFileHandle(this.fs, filename, this.ctx);
167
- }
168
- catch (error) {
169
- if (error instanceof DOMException)
170
- throw error;
171
- if (error && typeof error === 'object') {
172
- switch (error.code) {
173
- case 'ENOENT': {
174
- if (options === null || options === void 0 ? void 0 : options.create) {
175
- (0, util_1.assertCanWrite)(this.ctx.mode);
176
- yield this.fs.promises.writeFile(filename, '');
177
- return new NodeFileSystemFileHandle_1.NodeFileSystemFileHandle(this.fs, filename, this.ctx);
178
- }
179
- throw (0, util_1.newNotFoundError)();
124
+ async getFileHandle(name, options) {
125
+ (0, util_1.assertName)(name, 'getFileHandle', 'FileSystemDirectoryHandle');
126
+ const filename = this.__path + name;
127
+ try {
128
+ const stats = await this.fs.promises.stat(filename);
129
+ if (!stats.isFile())
130
+ throw (0, util_1.newTypeMismatchError)();
131
+ return new NodeFileSystemFileHandle_1.NodeFileSystemFileHandle(this.fs, filename, this.ctx);
132
+ }
133
+ catch (error) {
134
+ if (error instanceof DOMException)
135
+ throw error;
136
+ if (error && typeof error === 'object') {
137
+ switch (error.code) {
138
+ case 'ENOENT': {
139
+ if (options === null || options === void 0 ? void 0 : options.create) {
140
+ (0, util_1.assertCanWrite)(this.ctx.mode);
141
+ await this.fs.promises.writeFile(filename, '');
142
+ return new NodeFileSystemFileHandle_1.NodeFileSystemFileHandle(this.fs, filename, this.ctx);
180
143
  }
181
- case 'EPERM':
182
- case 'EACCES':
183
- throw (0, util_1.newNotAllowedError)();
144
+ throw (0, util_1.newNotFoundError)();
184
145
  }
146
+ case 'EPERM':
147
+ case 'EACCES':
148
+ throw (0, util_1.newNotAllowedError)();
185
149
  }
186
- throw error;
187
150
  }
188
- });
151
+ throw error;
152
+ }
189
153
  }
190
154
  /**
191
155
  * Attempts to remove an entry if the directory handle contains a file or
@@ -196,41 +160,39 @@ class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle_1.NodeFileSyste
196
160
  * entry you wish to remove.
197
161
  * @param options An optional object containing options.
198
162
  */
199
- removeEntry(name, { recursive = false } = {}) {
200
- return __awaiter(this, void 0, void 0, function* () {
201
- (0, util_1.assertCanWrite)(this.ctx.mode);
202
- (0, util_1.assertName)(name, 'removeEntry', 'FileSystemDirectoryHandle');
203
- const filename = this.__path + this.ctx.separator + name;
204
- const promises = this.fs.promises;
205
- try {
206
- const stats = yield promises.stat(filename);
207
- if (stats.isFile()) {
208
- yield promises.unlink(filename);
209
- }
210
- else if (stats.isDirectory()) {
211
- yield promises.rmdir(filename, { recursive });
212
- }
213
- else
214
- throw (0, util_1.newTypeMismatchError)();
163
+ async removeEntry(name, { recursive = false } = {}) {
164
+ (0, util_1.assertCanWrite)(this.ctx.mode);
165
+ (0, util_1.assertName)(name, 'removeEntry', 'FileSystemDirectoryHandle');
166
+ const filename = this.__path + name;
167
+ const promises = this.fs.promises;
168
+ try {
169
+ const stats = await promises.stat(filename);
170
+ if (stats.isFile()) {
171
+ await promises.unlink(filename);
215
172
  }
216
- catch (error) {
217
- if (error instanceof DOMException)
218
- throw error;
219
- if (error && typeof error === 'object') {
220
- switch (error.code) {
221
- case 'ENOENT': {
222
- throw (0, util_1.newNotFoundError)();
223
- }
224
- case 'EPERM':
225
- case 'EACCES':
226
- throw (0, util_1.newNotAllowedError)();
227
- case 'ENOTEMPTY':
228
- throw new DOMException('The object can not be modified in this way.', 'InvalidModificationError');
173
+ else if (stats.isDirectory()) {
174
+ await promises.rmdir(filename, { recursive });
175
+ }
176
+ else
177
+ throw (0, util_1.newTypeMismatchError)();
178
+ }
179
+ catch (error) {
180
+ if (error instanceof DOMException)
181
+ throw error;
182
+ if (error && typeof error === 'object') {
183
+ switch (error.code) {
184
+ case 'ENOENT': {
185
+ throw (0, util_1.newNotFoundError)();
229
186
  }
187
+ case 'EPERM':
188
+ case 'EACCES':
189
+ throw (0, util_1.newNotAllowedError)();
190
+ case 'ENOTEMPTY':
191
+ throw new DOMException('The object can not be modified in this way.', 'InvalidModificationError');
230
192
  }
231
- throw error;
232
193
  }
233
- });
194
+ throw error;
195
+ }
234
196
  }
235
197
  /**
236
198
  * The `resolve()` method of the {@link FileSystemDirectoryHandle} interface
@@ -241,24 +203,23 @@ class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle_1.NodeFileSyste
241
203
  * @param possibleDescendant The {@link NodeFileSystemFileHandle} from which
242
204
  * to return the relative path.
243
205
  */
244
- resolve(possibleDescendant) {
245
- return __awaiter(this, void 0, void 0, function* () {
246
- if (possibleDescendant instanceof NodeFileSystemDirectoryHandle ||
247
- possibleDescendant instanceof NodeFileSystemFileHandle_1.NodeFileSystemFileHandle) {
248
- const path = this.__path;
249
- const childPath = possibleDescendant.__path;
250
- if (!childPath.startsWith(path))
251
- return null;
252
- let relative = childPath.slice(path.length);
253
- if (relative === '')
254
- return [];
255
- const separator = this.ctx.separator;
256
- if (relative[0] === separator)
257
- relative = relative.slice(1);
258
- return relative.split(separator);
259
- }
260
- return null;
261
- });
206
+ async resolve(possibleDescendant) {
207
+ if (possibleDescendant instanceof NodeFileSystemDirectoryHandle ||
208
+ possibleDescendant instanceof NodeFileSystemFileHandle_1.NodeFileSystemFileHandle) {
209
+ const path = this.__path;
210
+ const childPath = possibleDescendant.__path;
211
+ if (!childPath.startsWith(path))
212
+ return null;
213
+ let relative = childPath.slice(path.length);
214
+ if (relative === '')
215
+ return [];
216
+ const separator = this.ctx.separator;
217
+ if (relative[0] === separator)
218
+ relative = relative.slice(1);
219
+ return relative.split(separator);
220
+ }
221
+ return null;
262
222
  }
263
223
  }
264
224
  exports.NodeFileSystemDirectoryHandle = NodeFileSystemDirectoryHandle;
225
+ //# sourceMappingURL=NodeFileSystemDirectoryHandle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeFileSystemDirectoryHandle.js","sourceRoot":"","sources":["../../src/node-to-fsa/NodeFileSystemDirectoryHandle.ts"],"names":[],"mappings":";;;;AAAA,iEAA8D;AAC9D,iCAQgB;AAChB,yEAAsE;AAWtE;;GAEG;AACH,MAAa,6BAA8B,SAAQ,2CAAoB;IAKrE,YAAsC,EAAa,EAAE,IAAY,EAAE,MAA+B,EAAE;QAClG,KAAK,CAAC,WAAW,EAAE,IAAA,eAAQ,EAAC,IAAI,EAAE,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,CAAC,CAAC;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CAAC,CAAC;wBACb,MAAM,IAAA,uBAAgB,GAAE,CAAC;qBAC1B;oBACD,KAAK,OAAO,CAAC;oBACb,KAAK,QAAQ;wBACX,MAAM,IAAA,yBAAkB,GAAE,CAAC;oBAC7B,KAAK,WAAW;wBACd,MAAM,IAAI,YAAY,CAAC,6CAA6C,EAAE,0BAA0B,CAAC,CAAC;iBACrG;aACF;YACD,MAAM,KAAK,CAAC;SACb;IACH,CAAC;IAED;;;;;;;;OAQG;IACI,KAAK,CAAC,OAAO,CAAC,kBAAwC;QAC3D,IACE,kBAAkB,YAAY,6BAA6B;YAC3D,kBAAkB,YAAY,mDAAwB,EACtD;YACA,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;YACzB,MAAM,SAAS,GAAG,kBAAkB,CAAC,MAAM,CAAC;YAC5C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC;gBAAE,OAAO,IAAI,CAAC;YAC7C,IAAI,QAAQ,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC5C,IAAI,QAAQ,KAAK,EAAE;gBAAE,OAAO,EAAE,CAAC;YAC/B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,SAAU,CAAC;YACtC,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,SAAS;gBAAE,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC5D,OAAO,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;SAClC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA7LD,sEA6LC"}
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.NodeFileSystemFileHandle = void 0;
13
4
  const NodeFileSystemHandle_1 = require("./NodeFileSystemHandle");
@@ -28,29 +19,28 @@ class NodeFileSystemFileHandle extends NodeFileSystemHandle_1.NodeFileSystemHand
28
19
  *
29
20
  * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/getFile
30
21
  */
31
- getFile() {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- try {
34
- const path = this.__path;
35
- const promises = this.fs.promises;
36
- const stats = yield promises.stat(path);
37
- const data = yield promises.readFile(path);
38
- const file = new File([data], this.name, { lastModified: stats.mtime.getTime() });
39
- return file;
40
- }
41
- catch (error) {
42
- if (error instanceof DOMException)
43
- throw error;
44
- if (error && typeof error === 'object') {
45
- switch (error.code) {
46
- case 'EPERM':
47
- case 'EACCES':
48
- throw (0, util_1.newNotAllowedError)();
49
- }
50
- }
22
+ async getFile() {
23
+ try {
24
+ const path = this.__path;
25
+ const promises = this.fs.promises;
26
+ const stats = await promises.stat(path);
27
+ // TODO: Once implemented, use promises.readAsBlob() instead of promises.readFile().
28
+ const data = await promises.readFile(path);
29
+ const file = new File([data], this.name, { lastModified: stats.mtime.getTime() });
30
+ return file;
31
+ }
32
+ catch (error) {
33
+ if (error instanceof DOMException)
51
34
  throw error;
35
+ if (error && typeof error === 'object') {
36
+ switch (error.code) {
37
+ case 'EPERM':
38
+ case 'EACCES':
39
+ throw (0, util_1.newNotAllowedError)();
40
+ }
52
41
  }
53
- });
42
+ throw error;
43
+ }
54
44
  }
55
45
  /**
56
46
  * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createSyncAccessHandle
@@ -58,16 +48,15 @@ class NodeFileSystemFileHandle extends NodeFileSystemHandle_1.NodeFileSystemHand
58
48
  get createSyncAccessHandle() {
59
49
  if (!this.ctx.syncHandleAllowed)
60
50
  return undefined;
61
- return () => __awaiter(this, void 0, void 0, function* () { return new NodeFileSystemSyncAccessHandle_1.NodeFileSystemSyncAccessHandle(this.fs, this.__path, this.ctx); });
51
+ return async () => new NodeFileSystemSyncAccessHandle_1.NodeFileSystemSyncAccessHandle(this.fs, this.__path, this.ctx);
62
52
  }
63
53
  /**
64
54
  * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createWritable
65
55
  */
66
- createWritable({ keepExistingData = false } = { keepExistingData: false }) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- (0, util_1.assertCanWrite)(this.ctx.mode);
69
- return new NodeFileSystemWritableFileStream_1.NodeFileSystemWritableFileStream(this.fs, this.__path, keepExistingData);
70
- });
56
+ async createWritable({ keepExistingData = false } = { keepExistingData: false }) {
57
+ (0, util_1.assertCanWrite)(this.ctx.mode);
58
+ return new NodeFileSystemWritableFileStream_1.NodeFileSystemWritableFileStream(this.fs, this.__path, keepExistingData);
71
59
  }
72
60
  }
73
61
  exports.NodeFileSystemFileHandle = NodeFileSystemFileHandle;
62
+ //# sourceMappingURL=NodeFileSystemFileHandle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeFileSystemFileHandle.js","sourceRoot":"","sources":["../../src/node-to-fsa/NodeFileSystemFileHandle.ts"],"names":[],"mappings":";;;AAAA,iEAA8D;AAC9D,qFAAkF;AAClF,iCAAwF;AACxF,yFAAsF;AAItF,MAAa,wBAAyB,SAAQ,2CAAoB;IAGhE,YAA+B,EAAa,EAAkB,MAAc,EAAE,MAA+B,EAAE;QAC7G,GAAG,GAAG,IAAA,UAAS,EAAC,GAAG,CAAC,CAAC;QACrB,KAAK,CAAC,MAAM,EAAE,IAAA,eAAQ,EAAC,MAAM,EAAE,GAAG,CAAC,SAAU,CAAC,CAAC,CAAC;QAFnB,OAAE,GAAF,EAA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AG,KAAK,KAA4B,EAAE,gBAAgB,EAAE,KAAK,EAAE;QAEjF,IAAA,qBAAc,EAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,IAAI,mEAAgC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACtF,CAAC;CACF;AAtDD,4DAsDC"}
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.NodeFileSystemHandle = void 0;
13
4
  /**
@@ -38,10 +29,8 @@ class NodeFileSystemHandle {
38
29
  /**
39
30
  * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/remove
40
31
  */
41
- remove({ recursive } = { recursive: false }) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- throw new Error('Not implemented');
44
- });
32
+ async remove({ recursive } = { recursive: false }) {
33
+ throw new Error('Not implemented');
45
34
  }
46
35
  /**
47
36
  * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/requestPermission
@@ -51,3 +40,4 @@ class NodeFileSystemHandle {
51
40
  }
52
41
  }
53
42
  exports.NodeFileSystemHandle = NodeFileSystemHandle;
43
+ //# sourceMappingURL=NodeFileSystemHandle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeFileSystemHandle.js","sourceRoot":"","sources":["../../src/node-to-fsa/NodeFileSystemHandle.ts"],"names":[],"mappings":";;;AAGA;;;;;GAKG;AACH,MAAsB,oBAAoB;IACxC,YAA4B,IAA0B,EAAkB,IAAY;QAAxD,SAAI,GAAJ,IAAI,CAAsB;QAAkB,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAExF;;;;OAIG;IACI,WAAW,CAAC,gBAAsC;QACvD,OAAO,CACL,IAAI,CAAC,WAAW,KAAK,gBAAgB,CAAC,WAAW,IAAK,IAAY,CAAC,MAAM,KAAM,gBAAwB,CAAC,MAAM,CAC/G,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,eAAe,CACpB,oCAA0E;QAE1E,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM,CAAC,EAAE,SAAS,KAA8B,EAAE,SAAS,EAAE,KAAK,EAAE;QAC/E,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACI,iBAAiB,CACtB,oCAA0E;QAE1E,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF;AAtCD,oDAsCC"}