@zenfs/core 0.16.3 → 0.17.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 (74) hide show
  1. package/dist/backends/backend.d.ts +3 -4
  2. package/dist/backends/fetch.d.ts +8 -3
  3. package/dist/backends/fetch.js +3 -2
  4. package/dist/backends/{index/fs.d.ts → file_index.d.ts} +49 -10
  5. package/dist/backends/{index/fs.js → file_index.js} +84 -5
  6. package/dist/backends/memory.d.ts +6 -1
  7. package/dist/backends/memory.js +2 -1
  8. package/dist/backends/overlay.d.ts +16 -16
  9. package/dist/backends/overlay.js +59 -82
  10. package/dist/backends/port/fs.d.ts +6 -2
  11. package/dist/backends/port/fs.js +4 -2
  12. package/dist/backends/store/fs.js +484 -304
  13. package/dist/backends/store/simple.js +5 -1
  14. package/dist/backends/store/store.d.ts +4 -1
  15. package/dist/backends/store/store.js +9 -5
  16. package/dist/browser.min.js +4 -4
  17. package/dist/browser.min.js.map +4 -4
  18. package/dist/config.d.ts +3 -3
  19. package/dist/emulation/async.d.ts +0 -3
  20. package/dist/emulation/async.js +6 -2
  21. package/dist/emulation/dir.d.ts +4 -0
  22. package/dist/emulation/dir.js +8 -6
  23. package/dist/emulation/promises.d.ts +1 -3
  24. package/dist/emulation/promises.js +26 -3
  25. package/dist/emulation/sync.js +1 -2
  26. package/dist/emulation/watchers.d.ts +9 -4
  27. package/dist/emulation/watchers.js +7 -0
  28. package/dist/file.d.ts +17 -1
  29. package/dist/file.js +86 -1
  30. package/dist/filesystem.d.ts +0 -63
  31. package/dist/filesystem.js +0 -311
  32. package/dist/index.d.ts +1 -2
  33. package/dist/index.js +1 -2
  34. package/dist/mixins/async.d.ts +39 -0
  35. package/dist/mixins/async.js +216 -0
  36. package/dist/mixins/mutexed.d.ts +33 -0
  37. package/dist/mixins/mutexed.js +465 -0
  38. package/dist/mixins/readonly.d.ts +25 -0
  39. package/dist/mixins/readonly.js +57 -0
  40. package/dist/mixins/shared.d.ts +12 -0
  41. package/dist/mixins/shared.js +4 -0
  42. package/dist/mixins/sync.d.ts +6 -0
  43. package/dist/mixins/sync.js +43 -0
  44. package/package.json +1 -1
  45. package/src/backends/backend.ts +3 -4
  46. package/src/backends/fetch.ts +7 -3
  47. package/src/backends/{index/fs.ts → file_index.ts} +106 -8
  48. package/src/backends/memory.ts +5 -1
  49. package/src/backends/overlay.ts +64 -90
  50. package/src/backends/port/fs.ts +7 -2
  51. package/src/backends/{index/readme.md → readme.md} +1 -1
  52. package/src/backends/store/fs.ts +97 -155
  53. package/src/backends/store/simple.ts +5 -1
  54. package/src/backends/store/store.ts +10 -5
  55. package/src/config.ts +3 -1
  56. package/src/emulation/async.ts +15 -6
  57. package/src/emulation/dir.ts +19 -16
  58. package/src/emulation/promises.ts +30 -8
  59. package/src/emulation/sync.ts +2 -3
  60. package/src/emulation/watchers.ts +10 -4
  61. package/src/file.ts +94 -1
  62. package/src/filesystem.ts +3 -366
  63. package/src/index.ts +1 -2
  64. package/src/mixins/async.ts +211 -0
  65. package/src/mixins/mutexed.ts +245 -0
  66. package/src/mixins/readonly.ts +97 -0
  67. package/src/mixins/shared.ts +20 -0
  68. package/src/mixins/sync.ts +59 -0
  69. package/dist/backends/index/index.d.ts +0 -43
  70. package/dist/backends/index/index.js +0 -83
  71. package/dist/backends/locked.d.ts +0 -92
  72. package/dist/backends/locked.js +0 -487
  73. package/src/backends/index/index.ts +0 -104
  74. package/src/backends/locked.ts +0 -264
@@ -69,9 +69,12 @@ export class SimpleTransaction extends SyncTransaction {
69
69
  this.store.delete(ino);
70
70
  }
71
71
  commitSync() {
72
- /* NOP */
72
+ this.done = true;
73
73
  }
74
74
  abortSync() {
75
+ if (!this.done) {
76
+ return;
77
+ }
75
78
  // Rollback old values.
76
79
  for (const key of this.modifiedKeys) {
77
80
  const value = this.originalData.get(key);
@@ -84,6 +87,7 @@ export class SimpleTransaction extends SyncTransaction {
84
87
  this.store.set(key, value);
85
88
  }
86
89
  }
90
+ this.done = true;
87
91
  }
88
92
  /**
89
93
  * Stashes given key value pair into `originalData` if it doesn't already
@@ -31,7 +31,10 @@ export interface Store {
31
31
  export declare abstract class Transaction<T extends Store = Store> {
32
32
  protected store: T;
33
33
  constructor(store: T);
34
- protected aborted: boolean;
34
+ /**
35
+ * Whether the transaction was commited or aborted
36
+ */
37
+ protected done: boolean;
35
38
  /**
36
39
  * Retrieves the data at the given key.
37
40
  * @param ino The key to look under for data.
@@ -6,25 +6,29 @@ import '../../polyfills.js';
6
6
  export class Transaction {
7
7
  constructor(store) {
8
8
  this.store = store;
9
- this.aborted = false;
9
+ /**
10
+ * Whether the transaction was commited or aborted
11
+ */
12
+ this.done = false;
10
13
  }
11
14
  async [Symbol.asyncDispose]() {
12
- if (this.aborted) {
15
+ if (this.done) {
13
16
  return;
14
17
  }
15
- await this.commit();
18
+ await this.abort();
16
19
  }
17
20
  [Symbol.dispose]() {
18
- if (this.aborted) {
21
+ if (this.done) {
19
22
  return;
20
23
  }
21
- this.commitSync();
24
+ this.abortSync();
22
25
  }
23
26
  }
24
27
  /**
25
28
  * Transaction that implements asynchronous operations with synchronous ones
26
29
  */
27
30
  export class SyncTransaction extends Transaction {
31
+ /* eslint-disable @typescript-eslint/require-await */
28
32
  async get(ino) {
29
33
  return this.getSync(ino);
30
34
  }