@zenfs/core 0.3.5 → 0.4.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 (47) hide show
  1. package/dist/FileIndex.d.ts +4 -0
  2. package/dist/FileIndex.js +3 -3
  3. package/dist/backends/AsyncMirror.d.ts +3 -5
  4. package/dist/backends/AsyncMirror.js +7 -6
  5. package/dist/backends/AsyncStore.d.ts +9 -4
  6. package/dist/backends/AsyncStore.js +7 -2
  7. package/dist/backends/Locked.d.ts +8 -8
  8. package/dist/backends/Locked.js +2 -1
  9. package/dist/backends/Overlay.d.ts +13 -1
  10. package/dist/backends/Overlay.js +16 -16
  11. package/dist/backends/SyncStore.d.ts +8 -5
  12. package/dist/backends/SyncStore.js +9 -5
  13. package/dist/backends/backend.js +8 -8
  14. package/dist/browser.min.js +4 -5
  15. package/dist/browser.min.js.map +4 -4
  16. package/dist/config.d.ts +23 -0
  17. package/dist/config.js +36 -0
  18. package/dist/cred.d.ts +1 -1
  19. package/dist/cred.js +1 -1
  20. package/dist/emulation/callbacks.d.ts +1 -1
  21. package/dist/emulation/callbacks.js +1 -1
  22. package/dist/emulation/constants.d.ts +48 -42
  23. package/dist/emulation/constants.js +68 -59
  24. package/dist/emulation/dir.d.ts +2 -2
  25. package/dist/emulation/promises.d.ts +1 -1
  26. package/dist/emulation/promises.js +6 -6
  27. package/dist/emulation/sync.d.ts +1 -1
  28. package/dist/emulation/sync.js +7 -7
  29. package/dist/file.d.ts +26 -12
  30. package/dist/file.js +68 -29
  31. package/dist/filesystem.d.ts +3 -3
  32. package/dist/index.d.ts +7 -29
  33. package/dist/index.js +7 -44
  34. package/dist/inode.d.ts +21 -15
  35. package/dist/inode.js +52 -40
  36. package/dist/mutex.d.ts +1 -2
  37. package/dist/mutex.js +1 -1
  38. package/dist/stats.d.ts +70 -18
  39. package/dist/stats.js +12 -18
  40. package/dist/utils.d.ts +3 -8
  41. package/dist/utils.js +60 -39
  42. package/license.md +3 -80
  43. package/package.json +71 -63
  44. package/readme.md +19 -11
  45. package/scripts/make-index.js +100 -0
  46. package/dist/backends/index.d.ts +0 -10
  47. package/dist/backends/index.js +0 -12
package/dist/file.js CHANGED
@@ -2,6 +2,9 @@ import { ApiError, ErrorCode } from './ApiError.js';
2
2
  import { O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY, S_IFMT } from './emulation/constants.js';
3
3
  import { size_max } from './inode.js';
4
4
  import { Stats } from './stats.js';
5
+ /**
6
+ * @hidden
7
+ */
5
8
  export var ActionType;
6
9
  (function (ActionType) {
7
10
  // Indicates that the code should not do anything.
@@ -38,33 +41,32 @@ export class FileFlag {
38
41
  * @return The FileFlag object representing the flag
39
42
  * @throw when the flag string is invalid
40
43
  */
41
- static FromString(flag) {
44
+ static Get(flag) {
42
45
  // Check cache first.
43
- if (!FileFlag.flagCache.has(flag)) {
44
- FileFlag.flagCache.set(flag, new FileFlag(flag));
46
+ if (!FileFlag.cache.has(flag)) {
47
+ FileFlag.cache.set(flag, new FileFlag(flag));
45
48
  }
46
- return FileFlag.flagCache.get(flag);
49
+ return FileFlag.cache.get(flag);
47
50
  }
48
51
  /**
49
- * This should never be called directly.
50
52
  * @param flag The string or number representing the flag
51
53
  * @throw when the flag is invalid
52
54
  */
53
55
  constructor(flag) {
54
- if (typeof flag === 'number') {
55
- flag = FileFlag.NumberToString(flag);
56
+ if (typeof flag == 'number') {
57
+ flag = FileFlag.StringOf(flag);
56
58
  }
57
- if (FileFlag.validFlagStrs.indexOf(flag) < 0) {
59
+ if (!FileFlag.validStrings.includes(flag)) {
58
60
  throw new ApiError(ErrorCode.EINVAL, 'Invalid flag string: ' + flag);
59
61
  }
60
- this.flagStr = flag;
62
+ this._flag = flag;
61
63
  }
62
64
  /**
63
65
  * @param flag The number representing the flag
64
- * @return The string representing the flag
65
- * @throw when the flag number is invalid
66
+ * @returns The string representing the flag
67
+ * @throws when the flag number is invalid
66
68
  */
67
- static NumberToString(flag) {
69
+ static StringOf(flag) {
68
70
  // based on https://github.com/nodejs/node/blob/abbdc3efaa455e6c907ebef5409ac8b0f222f969/lib/internal/fs/utils.js#L619
69
71
  switch (flag) {
70
72
  case O_RDONLY:
@@ -95,11 +97,46 @@ export class FileFlag {
95
97
  throw new ApiError(ErrorCode.EINVAL, 'Invalid flag number: ' + flag);
96
98
  }
97
99
  }
100
+ /**
101
+ * @param flag The string representing the flag
102
+ * @returns The number representing the flag
103
+ * @throws when the flag string is invalid
104
+ */
105
+ static NumberOf(flag) {
106
+ switch (flag) {
107
+ case 'r':
108
+ return O_RDONLY;
109
+ case 'rs':
110
+ return O_RDONLY | O_SYNC;
111
+ case 'r+':
112
+ return O_RDWR;
113
+ case 'rs+':
114
+ return O_RDWR | O_SYNC;
115
+ case 'w':
116
+ return O_TRUNC | O_CREAT | O_WRONLY;
117
+ case 'wx':
118
+ return O_TRUNC | O_CREAT | O_WRONLY | O_EXCL;
119
+ case 'w+':
120
+ return O_TRUNC | O_CREAT | O_RDWR;
121
+ case 'wx+':
122
+ return O_TRUNC | O_CREAT | O_RDWR | O_EXCL;
123
+ case 'a':
124
+ return O_APPEND | O_CREAT | O_WRONLY;
125
+ case 'ax':
126
+ return O_APPEND | O_CREAT | O_WRONLY | O_EXCL;
127
+ case 'a+':
128
+ return O_APPEND | O_CREAT | O_RDWR;
129
+ case 'ax+':
130
+ return O_APPEND | O_CREAT | O_RDWR | O_EXCL;
131
+ default:
132
+ throw new ApiError(ErrorCode.EINVAL, 'Invalid flag string: ' + flag);
133
+ }
134
+ }
98
135
  /**
99
136
  * Get the underlying flag string for this flag.
100
137
  */
101
138
  toString() {
102
- return this.flagStr;
139
+ return this._flag;
103
140
  }
104
141
  /**
105
142
  * Get the equivalent mode (0b0xxx: read, write, execute)
@@ -118,37 +155,37 @@ export class FileFlag {
118
155
  * Returns true if the file is readable.
119
156
  */
120
157
  isReadable() {
121
- return this.flagStr.indexOf('r') !== -1 || this.flagStr.indexOf('+') !== -1;
158
+ return this._flag.indexOf('r') != -1 || this._flag.indexOf('+') != -1;
122
159
  }
123
160
  /**
124
161
  * Returns true if the file is writeable.
125
162
  */
126
163
  isWriteable() {
127
- return this.flagStr.indexOf('w') !== -1 || this.flagStr.indexOf('a') !== -1 || this.flagStr.indexOf('+') !== -1;
164
+ return this._flag.indexOf('w') != -1 || this._flag.indexOf('a') != -1 || this._flag.indexOf('+') != -1;
128
165
  }
129
166
  /**
130
167
  * Returns true if the file mode should truncate.
131
168
  */
132
169
  isTruncating() {
133
- return this.flagStr.indexOf('w') !== -1;
170
+ return this._flag.indexOf('w') !== -1;
134
171
  }
135
172
  /**
136
173
  * Returns true if the file is appendable.
137
174
  */
138
175
  isAppendable() {
139
- return this.flagStr.indexOf('a') !== -1;
176
+ return this._flag.indexOf('a') !== -1;
140
177
  }
141
178
  /**
142
179
  * Returns true if the file is open in synchronous mode.
143
180
  */
144
181
  isSynchronous() {
145
- return this.flagStr.indexOf('s') !== -1;
182
+ return this._flag.indexOf('s') !== -1;
146
183
  }
147
184
  /**
148
185
  * Returns true if the file is open in exclusive mode.
149
186
  */
150
187
  isExclusive() {
151
- return this.flagStr.indexOf('x') !== -1;
188
+ return this._flag.indexOf('x') !== -1;
152
189
  }
153
190
  /**
154
191
  * Returns one of the static fields on this object that indicates the
@@ -168,18 +205,20 @@ export class FileFlag {
168
205
  * appropriate response to the path not existing.
169
206
  */
170
207
  pathNotExistsAction() {
171
- if ((this.isWriteable() || this.isAppendable()) && this.flagStr !== 'r+') {
208
+ if ((this.isWriteable() || this.isAppendable()) && this._flag != 'r+') {
172
209
  return ActionType.CREATE;
173
210
  }
174
- else {
175
- return ActionType.THROW;
176
- }
211
+ return ActionType.THROW;
177
212
  }
178
213
  }
179
- // Contains cached FileMode instances.
180
- FileFlag.flagCache = new Map();
181
- // Array of valid mode strings.
182
- FileFlag.validFlagStrs = ['r', 'r+', 'rs', 'rs+', 'w', 'wx', 'w+', 'wx+', 'a', 'ax', 'a+', 'ax+'];
214
+ /**
215
+ * Contains cached FileMode instances.
216
+ */
217
+ FileFlag.cache = new Map();
218
+ /**
219
+ * Array of valid mode strings.
220
+ */
221
+ FileFlag.validStrings = ['r', 'r+', 'rs', 'rs+', 'w', 'wx', 'w+', 'wx+', 'a', 'ax', 'a+', 'ax+'];
183
222
  export class File {
184
223
  /**
185
224
  * Asynchronous `datasync`.
@@ -282,13 +321,13 @@ export class PreloadFile extends File {
282
321
  * Asynchronous `stat`.
283
322
  */
284
323
  async stat() {
285
- return Stats.clone(this.stats);
324
+ return new Stats(this.stats);
286
325
  }
287
326
  /**
288
327
  * Synchronous `stat`.
289
328
  */
290
329
  statSync() {
291
- return Stats.clone(this.stats);
330
+ return new Stats(this.stats);
292
331
  }
293
332
  /**
294
333
  * Asynchronous truncate.
@@ -1,7 +1,7 @@
1
1
  import { ApiError } from './ApiError.js';
2
- import { Stats } from './stats.js';
3
- import { File, FileFlag } from './file.js';
4
- import { Cred } from './cred.js';
2
+ import type { Stats } from './stats.js';
3
+ import type { File, FileFlag } from './file.js';
4
+ import type { Cred } from './cred.js';
5
5
  export type NoArgCallback = (e?: ApiError) => unknown;
6
6
  export type TwoArgCallback<T> = (e?: ApiError, rv?: T) => unknown;
7
7
  export type ThreeArgCallback<T, U> = (e?: ApiError, arg1?: T, arg2?: U) => unknown;
package/dist/index.d.ts CHANGED
@@ -1,35 +1,12 @@
1
- /**
2
- * ZenFS's main module. This is exposed in the browser via the ZenFS global.
3
- */
4
- import * as fs from './emulation/index.js';
5
- import { FileSystem } from './filesystem.js';
6
- import { backends } from './backends/index.js';
7
- import { type Backend, type BackendConfig } from './backends/backend.js';
8
- /**
9
- * Initializes ZenFS with the given file systems.
10
- */
11
- export declare function initialize(mounts: {
12
- [point: string]: FileSystem;
13
- }, uid?: number, gid?: number): void;
14
- /**
15
- * Defines a mapping of mount points to their configurations
16
- */
17
- export interface ConfigMapping {
18
- [mountPoint: string]: FileSystem | BackendConfig | keyof typeof backends | Backend;
19
- }
20
- /**
21
- * A configuration for ZenFS
22
- */
23
- export type Configuration = FileSystem | BackendConfig | ConfigMapping;
24
- /**
25
- * Creates filesystems with the given configuration, and initializes ZenFS with it.
26
- * See the Configuration type for more info on the configuration object.
27
- */
28
- export declare function configure(config: Configuration): Promise<void>;
29
- export * from './backends/index.js';
1
+ export * from './backends/backend.js';
2
+ export * from './backends/AsyncMirror.js';
30
3
  export * from './backends/AsyncStore.js';
4
+ export * from './backends/InMemory.js';
5
+ export * from './backends/Locked.js';
6
+ export * from './backends/Overlay.js';
31
7
  export * from './backends/SyncStore.js';
32
8
  export * from './ApiError.js';
9
+ export * from './config.js';
33
10
  export * from './cred.js';
34
11
  export * from './file.js';
35
12
  export * from './filesystem.js';
@@ -38,5 +15,6 @@ export * from './inode.js';
38
15
  export * from './mutex.js';
39
16
  export * from './stats.js';
40
17
  export * from './utils.js';
18
+ import * as fs from './emulation/index.js';
41
19
  export { fs };
42
20
  export default fs;
package/dist/index.js CHANGED
@@ -1,50 +1,12 @@
1
- /**
2
- * ZenFS's main module. This is exposed in the browser via the ZenFS global.
3
- */
4
- import * as fs from './emulation/index.js';
5
- import { FileSystem } from './filesystem.js';
6
- import { backends } from './backends/index.js';
7
- import { Cred } from './cred.js';
8
- import { isBackend, resolveBackendConfig } from './backends/backend.js';
9
- import { setCred } from './emulation/shared.js';
10
- /**
11
- * Initializes ZenFS with the given file systems.
12
- */
13
- export function initialize(mounts, uid = 0, gid = 0) {
14
- setCred(new Cred(uid, gid, uid, gid, uid, gid));
15
- fs.initialize(mounts);
16
- }
17
- /**
18
- * Creates filesystems with the given configuration, and initializes ZenFS with it.
19
- * See the Configuration type for more info on the configuration object.
20
- */
21
- export async function configure(config) {
22
- if ('backend' in config || config instanceof FileSystem) {
23
- // single FS
24
- config = { '/': config };
25
- }
26
- for (let [point, value] of Object.entries(config)) {
27
- if (typeof value == 'number') {
28
- //should never happen
29
- continue;
30
- }
31
- if (value instanceof FileSystem) {
32
- continue;
33
- }
34
- if (typeof value == 'string') {
35
- value = { backend: backends[value] };
36
- }
37
- if (isBackend(value)) {
38
- value = { backend: value };
39
- }
40
- config[point] = await resolveBackendConfig(value);
41
- }
42
- initialize(config);
43
- }
44
- export * from './backends/index.js';
1
+ export * from './backends/backend.js';
2
+ export * from './backends/AsyncMirror.js';
45
3
  export * from './backends/AsyncStore.js';
4
+ export * from './backends/InMemory.js';
5
+ export * from './backends/Locked.js';
6
+ export * from './backends/Overlay.js';
46
7
  export * from './backends/SyncStore.js';
47
8
  export * from './ApiError.js';
9
+ export * from './config.js';
48
10
  export * from './cred.js';
49
11
  export * from './file.js';
50
12
  export * from './filesystem.js';
@@ -53,5 +15,6 @@ export * from './inode.js';
53
15
  export * from './mutex.js';
54
16
  export * from './stats.js';
55
17
  export * from './utils.js';
18
+ import * as fs from './emulation/index.js';
56
19
  export { fs };
57
20
  export default fs;
package/dist/inode.d.ts CHANGED
@@ -1,20 +1,28 @@
1
- import { Stats } from './stats.js';
1
+ import { Stats, type StatsLike } from './stats.js';
2
+ /**
3
+ * Alias for an ino.
4
+ * This will be helpful if in the future inode numbers/IDs are changed to strings or numbers.
5
+ */
2
6
  export type Ino = bigint;
7
+ /**
8
+ * Max 32-bit integer
9
+ * @hidden
10
+ */
3
11
  export declare const size_max: number;
4
12
  /**
5
- * @internal
13
+ * Room inode
14
+ * @hidden
6
15
  */
7
16
  export declare const rootIno: Ino;
8
17
  /**
9
- * Generate 4 random bits at a time
10
- *
18
+ * Generate a random ino
11
19
  * @internal
12
20
  */
13
21
  export declare function randomIno(): Ino;
14
22
  /**
15
23
  * Generic inode definition that can easily be serialized.
16
24
  */
17
- export declare class Inode {
25
+ export declare class Inode implements StatsLike {
18
26
  readonly buffer: ArrayBufferLike;
19
27
  get data(): Uint8Array;
20
28
  protected view: DataView;
@@ -31,20 +39,18 @@ export declare class Inode {
31
39
  set uid(value: number);
32
40
  get gid(): number;
33
41
  set gid(value: number);
34
- get atime(): number;
35
- set atime(value: number);
36
- get mtime(): number;
37
- set mtime(value: number);
38
- get ctime(): number;
39
- set ctime(value: number);
42
+ get atimeMs(): number;
43
+ set atimeMs(value: number);
44
+ get birthtimeMs(): number;
45
+ set birthtimeMs(value: number);
46
+ get mtimeMs(): number;
47
+ set mtimeMs(value: number);
48
+ get ctimeMs(): number;
49
+ set ctimeMs(value: number);
40
50
  /**
41
51
  * Handy function that converts the Inode to a Node Stats object.
42
52
  */
43
53
  toStats(): Stats;
44
- /**
45
- * Get the size of this Inode, in bytes.
46
- */
47
- sizeof(): number;
48
54
  /**
49
55
  * Updates the Inode using information from the stats object. Used by file
50
56
  * systems at sync time, e.g.:
package/dist/inode.js CHANGED
@@ -1,20 +1,12 @@
1
- import { S_IFMT } from './emulation/constants.js';
2
- import { Stats, FileType } from './stats.js';
3
- var Offset;
4
- (function (Offset) {
5
- Offset[Offset["ino"] = 0] = "ino";
6
- Offset[Offset["size"] = 8] = "size";
7
- Offset[Offset["mode"] = 12] = "mode";
8
- Offset[Offset["nlink"] = 14] = "nlink";
9
- Offset[Offset["uid"] = 18] = "uid";
10
- Offset[Offset["gid"] = 22] = "gid";
11
- Offset[Offset["atime"] = 26] = "atime";
12
- Offset[Offset["mtime"] = 34] = "mtime";
13
- Offset[Offset["ctime"] = 42] = "ctime";
14
- })(Offset || (Offset = {}));
1
+ import { Stats } from './stats.js';
2
+ /**
3
+ * Max 32-bit integer
4
+ * @hidden
5
+ */
15
6
  export const size_max = 2 ** 32 - 1;
16
7
  /**
17
- * @internal
8
+ * Room inode
9
+ * @hidden
18
10
  */
19
11
  export const rootIno = 0n;
20
12
  /**
@@ -24,13 +16,29 @@ function _random() {
24
16
  return Math.round(Math.random() * 2 ** 32).toString(16);
25
17
  }
26
18
  /**
27
- * Generate 4 random bits at a time
28
- *
19
+ * Generate a random ino
29
20
  * @internal
30
21
  */
31
22
  export function randomIno() {
32
23
  return BigInt('0x' + _random() + _random());
33
24
  }
25
+ /**
26
+ * Offsets for inode members
27
+ */
28
+ var Offset;
29
+ (function (Offset) {
30
+ Offset[Offset["ino"] = 0] = "ino";
31
+ Offset[Offset["size"] = 8] = "size";
32
+ Offset[Offset["mode"] = 12] = "mode";
33
+ Offset[Offset["nlink"] = 14] = "nlink";
34
+ Offset[Offset["uid"] = 18] = "uid";
35
+ Offset[Offset["gid"] = 22] = "gid";
36
+ Offset[Offset["atime"] = 26] = "atime";
37
+ Offset[Offset["birthtime"] = 34] = "birthtime";
38
+ Offset[Offset["mtime"] = 42] = "mtime";
39
+ Offset[Offset["ctime"] = 50] = "ctime";
40
+ Offset[Offset["end"] = 58] = "end";
41
+ })(Offset || (Offset = {}));
34
42
  /**
35
43
  * Generic inode definition that can easily be serialized.
36
44
  */
@@ -40,7 +48,10 @@ export class Inode {
40
48
  }
41
49
  constructor(buffer) {
42
50
  const setDefaults = !buffer;
43
- buffer ?? (buffer = new ArrayBuffer(50));
51
+ buffer ?? (buffer = new ArrayBuffer(Offset.end));
52
+ if (buffer?.byteLength < Offset.end) {
53
+ throw new RangeError(`Can not create an inode from a buffer less than ${Offset.end} bytes`);
54
+ }
44
55
  this.view = new DataView(buffer);
45
56
  this.buffer = buffer;
46
57
  if (!setDefaults) {
@@ -51,9 +62,10 @@ export class Inode {
51
62
  this.nlink = 1;
52
63
  this.size = 4096;
53
64
  const now = Date.now();
54
- this.atime = now;
55
- this.mtime = now;
56
- this.ctime = now;
65
+ this.atimeMs = now;
66
+ this.mtimeMs = now;
67
+ this.ctimeMs = now;
68
+ this.birthtimeMs = now;
57
69
  }
58
70
  get ino() {
59
71
  return this.view.getBigUint64(Offset.ino, true);
@@ -91,35 +103,35 @@ export class Inode {
91
103
  set gid(value) {
92
104
  this.view.setUint32(Offset.gid, value, true);
93
105
  }
94
- get atime() {
106
+ get atimeMs() {
95
107
  return this.view.getFloat64(Offset.atime, true);
96
108
  }
97
- set atime(value) {
109
+ set atimeMs(value) {
98
110
  this.view.setFloat64(Offset.atime, value, true);
99
111
  }
100
- get mtime() {
112
+ get birthtimeMs() {
113
+ return this.view.getFloat64(Offset.birthtime, true);
114
+ }
115
+ set birthtimeMs(value) {
116
+ this.view.setFloat64(Offset.birthtime, value, true);
117
+ }
118
+ get mtimeMs() {
101
119
  return this.view.getFloat64(Offset.mtime, true);
102
120
  }
103
- set mtime(value) {
121
+ set mtimeMs(value) {
104
122
  this.view.setFloat64(Offset.mtime, value, true);
105
123
  }
106
- get ctime() {
124
+ get ctimeMs() {
107
125
  return this.view.getFloat64(Offset.ctime, true);
108
126
  }
109
- set ctime(value) {
127
+ set ctimeMs(value) {
110
128
  this.view.setFloat64(Offset.ctime, value, true);
111
129
  }
112
130
  /**
113
131
  * Handy function that converts the Inode to a Node Stats object.
114
132
  */
115
133
  toStats() {
116
- return new Stats((this.mode & S_IFMT) === FileType.DIRECTORY ? FileType.DIRECTORY : FileType.FILE, this.size, this.mode, this.atime, this.mtime, this.ctime, this.uid, this.gid);
117
- }
118
- /**
119
- * Get the size of this Inode, in bytes.
120
- */
121
- sizeof() {
122
- return this.buffer.byteLength;
134
+ return new Stats(this);
123
135
  }
124
136
  /**
125
137
  * Updates the Inode using information from the stats object. Used by file
@@ -153,16 +165,16 @@ export class Inode {
153
165
  this.uid = stats.uid;
154
166
  hasChanged = true;
155
167
  }
156
- if (this.atime !== stats.atimeMs) {
157
- this.atime = stats.atimeMs;
168
+ if (this.atimeMs !== stats.atimeMs) {
169
+ this.atimeMs = stats.atimeMs;
158
170
  hasChanged = true;
159
171
  }
160
- if (this.mtime !== stats.mtimeMs) {
161
- this.mtime = stats.mtimeMs;
172
+ if (this.mtimeMs !== stats.mtimeMs) {
173
+ this.mtimeMs = stats.mtimeMs;
162
174
  hasChanged = true;
163
175
  }
164
- if (this.ctime !== stats.ctimeMs) {
165
- this.ctime = stats.ctimeMs;
176
+ if (this.ctimeMs !== stats.ctimeMs) {
177
+ this.ctimeMs = stats.ctimeMs;
166
178
  hasChanged = true;
167
179
  }
168
180
  return hasChanged;
package/dist/mutex.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- export type MutexCallback = () => void;
2
1
  /**
3
2
  * Non-recursive mutex
4
3
  * @internal
5
4
  */
6
- export default class Mutex {
5
+ export declare class Mutex {
7
6
  private _locks;
8
7
  lock(path: string): Promise<void>;
9
8
  unlock(path: string): void;
package/dist/mutex.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Non-recursive mutex
3
3
  * @internal
4
4
  */
5
- export default class Mutex {
5
+ export class Mutex {
6
6
  constructor() {
7
7
  this._locks = new Map();
8
8
  }