@zenfs/core 0.0.12 → 0.1.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.
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  var _a;
11
2
  import { BaseFileSystem } from '../filesystem.js';
12
3
  import { relative, join } from '../emulation/path.js';
@@ -42,21 +33,19 @@ export class FolderAdapter extends BaseFileSystem {
42
33
  this._ready = this._initialize();
43
34
  }
44
35
  get metadata() {
45
- return Object.assign(Object.assign(Object.assign({}, super.metadata), this._wrapped.metadata), { supportsLinks: false });
36
+ return { ...super.metadata, ...this._wrapped.metadata, supportsLinks: false };
46
37
  }
47
38
  /**
48
39
  * Initialize the file system. Ensures that the wrapped file system
49
40
  * has the given folder.
50
41
  */
51
- _initialize() {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- const exists = yield this._wrapped.exists(this._folder, Cred.Root);
54
- if (!exists && this._wrapped.metadata.readonly) {
55
- throw ApiError.ENOENT(this._folder);
56
- }
57
- yield this._wrapped.mkdir(this._folder, 0o777, Cred.Root);
58
- return this;
59
- });
42
+ async _initialize() {
43
+ const exists = await this._wrapped.exists(this._folder, Cred.Root);
44
+ if (!exists && this._wrapped.metadata.readonly) {
45
+ throw ApiError.ENOENT(this._folder);
46
+ }
47
+ await this._wrapped.mkdir(this._folder, 0o777, Cred.Root);
48
+ return this;
60
49
  }
61
50
  }
62
51
  _a = FolderAdapter;
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import Mutex from '../mutex.js';
11
2
  /**
12
3
  * This class serializes access to an underlying async filesystem.
@@ -27,17 +18,18 @@ export default class LockedFS {
27
18
  return this._ready;
28
19
  }
29
20
  get metadata() {
30
- return Object.assign(Object.assign({}, this._fs.metadata), { name: 'LockedFS<' + this._fs.metadata.name + '>' });
21
+ return {
22
+ ...this._fs.metadata,
23
+ name: 'LockedFS<' + this._fs.metadata.name + '>',
24
+ };
31
25
  }
32
26
  get fs() {
33
27
  return this._fs;
34
28
  }
35
- rename(oldPath, newPath, cred) {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- yield this._mu.lock(oldPath);
38
- yield this._fs.rename(oldPath, newPath, cred);
39
- this._mu.unlock(oldPath);
40
- });
29
+ async rename(oldPath, newPath, cred) {
30
+ await this._mu.lock(oldPath);
31
+ await this._fs.rename(oldPath, newPath, cred);
32
+ this._mu.unlock(oldPath);
41
33
  }
42
34
  renameSync(oldPath, newPath, cred) {
43
35
  if (this._mu.isLocked(oldPath)) {
@@ -45,13 +37,11 @@ export default class LockedFS {
45
37
  }
46
38
  return this._fs.renameSync(oldPath, newPath, cred);
47
39
  }
48
- stat(p, cred) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- yield this._mu.lock(p);
51
- const stats = yield this._fs.stat(p, cred);
52
- this._mu.unlock(p);
53
- return stats;
54
- });
40
+ async stat(p, cred) {
41
+ await this._mu.lock(p);
42
+ const stats = await this._fs.stat(p, cred);
43
+ this._mu.unlock(p);
44
+ return stats;
55
45
  }
56
46
  statSync(p, cred) {
57
47
  if (this._mu.isLocked(p)) {
@@ -59,12 +49,10 @@ export default class LockedFS {
59
49
  }
60
50
  return this._fs.statSync(p, cred);
61
51
  }
62
- access(p, mode, cred) {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- yield this._mu.lock(p);
65
- yield this._fs.access(p, mode, cred);
66
- this._mu.unlock(p);
67
- });
52
+ async access(p, mode, cred) {
53
+ await this._mu.lock(p);
54
+ await this._fs.access(p, mode, cred);
55
+ this._mu.unlock(p);
68
56
  }
69
57
  accessSync(p, mode, cred) {
70
58
  if (this._mu.isLocked(p)) {
@@ -72,13 +60,11 @@ export default class LockedFS {
72
60
  }
73
61
  return this._fs.accessSync(p, mode, cred);
74
62
  }
75
- open(p, flag, mode, cred) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- yield this._mu.lock(p);
78
- const fd = yield this._fs.open(p, flag, mode, cred);
79
- this._mu.unlock(p);
80
- return fd;
81
- });
63
+ async open(p, flag, mode, cred) {
64
+ await this._mu.lock(p);
65
+ const fd = await this._fs.open(p, flag, mode, cred);
66
+ this._mu.unlock(p);
67
+ return fd;
82
68
  }
83
69
  openSync(p, flag, mode, cred) {
84
70
  if (this._mu.isLocked(p)) {
@@ -86,12 +72,10 @@ export default class LockedFS {
86
72
  }
87
73
  return this._fs.openSync(p, flag, mode, cred);
88
74
  }
89
- unlink(p, cred) {
90
- return __awaiter(this, void 0, void 0, function* () {
91
- yield this._mu.lock(p);
92
- yield this._fs.unlink(p, cred);
93
- this._mu.unlock(p);
94
- });
75
+ async unlink(p, cred) {
76
+ await this._mu.lock(p);
77
+ await this._fs.unlink(p, cred);
78
+ this._mu.unlock(p);
95
79
  }
96
80
  unlinkSync(p, cred) {
97
81
  if (this._mu.isLocked(p)) {
@@ -99,12 +83,10 @@ export default class LockedFS {
99
83
  }
100
84
  return this._fs.unlinkSync(p, cred);
101
85
  }
102
- rmdir(p, cred) {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- yield this._mu.lock(p);
105
- yield this._fs.rmdir(p, cred);
106
- this._mu.unlock(p);
107
- });
86
+ async rmdir(p, cred) {
87
+ await this._mu.lock(p);
88
+ await this._fs.rmdir(p, cred);
89
+ this._mu.unlock(p);
108
90
  }
109
91
  rmdirSync(p, cred) {
110
92
  if (this._mu.isLocked(p)) {
@@ -112,12 +94,10 @@ export default class LockedFS {
112
94
  }
113
95
  return this._fs.rmdirSync(p, cred);
114
96
  }
115
- mkdir(p, mode, cred) {
116
- return __awaiter(this, void 0, void 0, function* () {
117
- yield this._mu.lock(p);
118
- yield this._fs.mkdir(p, mode, cred);
119
- this._mu.unlock(p);
120
- });
97
+ async mkdir(p, mode, cred) {
98
+ await this._mu.lock(p);
99
+ await this._fs.mkdir(p, mode, cred);
100
+ this._mu.unlock(p);
121
101
  }
122
102
  mkdirSync(p, mode, cred) {
123
103
  if (this._mu.isLocked(p)) {
@@ -125,13 +105,11 @@ export default class LockedFS {
125
105
  }
126
106
  return this._fs.mkdirSync(p, mode, cred);
127
107
  }
128
- readdir(p, cred) {
129
- return __awaiter(this, void 0, void 0, function* () {
130
- yield this._mu.lock(p);
131
- const files = yield this._fs.readdir(p, cred);
132
- this._mu.unlock(p);
133
- return files;
134
- });
108
+ async readdir(p, cred) {
109
+ await this._mu.lock(p);
110
+ const files = await this._fs.readdir(p, cred);
111
+ this._mu.unlock(p);
112
+ return files;
135
113
  }
136
114
  readdirSync(p, cred) {
137
115
  if (this._mu.isLocked(p)) {
@@ -139,13 +117,11 @@ export default class LockedFS {
139
117
  }
140
118
  return this._fs.readdirSync(p, cred);
141
119
  }
142
- exists(p, cred) {
143
- return __awaiter(this, void 0, void 0, function* () {
144
- yield this._mu.lock(p);
145
- const exists = yield this._fs.exists(p, cred);
146
- this._mu.unlock(p);
147
- return exists;
148
- });
120
+ async exists(p, cred) {
121
+ await this._mu.lock(p);
122
+ const exists = await this._fs.exists(p, cred);
123
+ this._mu.unlock(p);
124
+ return exists;
149
125
  }
150
126
  existsSync(p, cred) {
151
127
  if (this._mu.isLocked(p)) {
@@ -153,13 +129,11 @@ export default class LockedFS {
153
129
  }
154
130
  return this._fs.existsSync(p, cred);
155
131
  }
156
- realpath(p, cred) {
157
- return __awaiter(this, void 0, void 0, function* () {
158
- yield this._mu.lock(p);
159
- const resolvedPath = yield this._fs.realpath(p, cred);
160
- this._mu.unlock(p);
161
- return resolvedPath;
162
- });
132
+ async realpath(p, cred) {
133
+ await this._mu.lock(p);
134
+ const resolvedPath = await this._fs.realpath(p, cred);
135
+ this._mu.unlock(p);
136
+ return resolvedPath;
163
137
  }
164
138
  realpathSync(p, cred) {
165
139
  if (this._mu.isLocked(p)) {
@@ -167,12 +141,10 @@ export default class LockedFS {
167
141
  }
168
142
  return this._fs.realpathSync(p, cred);
169
143
  }
170
- truncate(p, len, cred) {
171
- return __awaiter(this, void 0, void 0, function* () {
172
- yield this._mu.lock(p);
173
- yield this._fs.truncate(p, len, cred);
174
- this._mu.unlock(p);
175
- });
144
+ async truncate(p, len, cred) {
145
+ await this._mu.lock(p);
146
+ await this._fs.truncate(p, len, cred);
147
+ this._mu.unlock(p);
176
148
  }
177
149
  truncateSync(p, len, cred) {
178
150
  if (this._mu.isLocked(p)) {
@@ -180,13 +152,11 @@ export default class LockedFS {
180
152
  }
181
153
  return this._fs.truncateSync(p, len, cred);
182
154
  }
183
- readFile(fname, flag, cred) {
184
- return __awaiter(this, void 0, void 0, function* () {
185
- yield this._mu.lock(fname);
186
- const data = yield this._fs.readFile(fname, flag, cred);
187
- this._mu.unlock(fname);
188
- return data;
189
- });
155
+ async readFile(fname, flag, cred) {
156
+ await this._mu.lock(fname);
157
+ const data = await this._fs.readFile(fname, flag, cred);
158
+ this._mu.unlock(fname);
159
+ return data;
190
160
  }
191
161
  readFileSync(fname, flag, cred) {
192
162
  if (this._mu.isLocked(fname)) {
@@ -194,12 +164,10 @@ export default class LockedFS {
194
164
  }
195
165
  return this._fs.readFileSync(fname, flag, cred);
196
166
  }
197
- writeFile(fname, data, flag, mode, cred) {
198
- return __awaiter(this, void 0, void 0, function* () {
199
- yield this._mu.lock(fname);
200
- yield this._fs.writeFile(fname, data, flag, mode, cred);
201
- this._mu.unlock(fname);
202
- });
167
+ async writeFile(fname, data, flag, mode, cred) {
168
+ await this._mu.lock(fname);
169
+ await this._fs.writeFile(fname, data, flag, mode, cred);
170
+ this._mu.unlock(fname);
203
171
  }
204
172
  writeFileSync(fname, data, flag, mode, cred) {
205
173
  if (this._mu.isLocked(fname)) {
@@ -207,12 +175,10 @@ export default class LockedFS {
207
175
  }
208
176
  return this._fs.writeFileSync(fname, data, flag, mode, cred);
209
177
  }
210
- appendFile(fname, data, flag, mode, cred) {
211
- return __awaiter(this, void 0, void 0, function* () {
212
- yield this._mu.lock(fname);
213
- yield this._fs.appendFile(fname, data, flag, mode, cred);
214
- this._mu.unlock(fname);
215
- });
178
+ async appendFile(fname, data, flag, mode, cred) {
179
+ await this._mu.lock(fname);
180
+ await this._fs.appendFile(fname, data, flag, mode, cred);
181
+ this._mu.unlock(fname);
216
182
  }
217
183
  appendFileSync(fname, data, flag, mode, cred) {
218
184
  if (this._mu.isLocked(fname)) {
@@ -220,12 +186,10 @@ export default class LockedFS {
220
186
  }
221
187
  return this._fs.appendFileSync(fname, data, flag, mode, cred);
222
188
  }
223
- chmod(p, mode, cred) {
224
- return __awaiter(this, void 0, void 0, function* () {
225
- yield this._mu.lock(p);
226
- yield this._fs.chmod(p, mode, cred);
227
- this._mu.unlock(p);
228
- });
189
+ async chmod(p, mode, cred) {
190
+ await this._mu.lock(p);
191
+ await this._fs.chmod(p, mode, cred);
192
+ this._mu.unlock(p);
229
193
  }
230
194
  chmodSync(p, mode, cred) {
231
195
  if (this._mu.isLocked(p)) {
@@ -233,12 +197,10 @@ export default class LockedFS {
233
197
  }
234
198
  return this._fs.chmodSync(p, mode, cred);
235
199
  }
236
- chown(p, new_uid, new_gid, cred) {
237
- return __awaiter(this, void 0, void 0, function* () {
238
- yield this._mu.lock(p);
239
- yield this._fs.chown(p, new_uid, new_gid, cred);
240
- this._mu.unlock(p);
241
- });
200
+ async chown(p, new_uid, new_gid, cred) {
201
+ await this._mu.lock(p);
202
+ await this._fs.chown(p, new_uid, new_gid, cred);
203
+ this._mu.unlock(p);
242
204
  }
243
205
  chownSync(p, new_uid, new_gid, cred) {
244
206
  if (this._mu.isLocked(p)) {
@@ -246,12 +208,10 @@ export default class LockedFS {
246
208
  }
247
209
  return this._fs.chownSync(p, new_uid, new_gid, cred);
248
210
  }
249
- utimes(p, atime, mtime, cred) {
250
- return __awaiter(this, void 0, void 0, function* () {
251
- yield this._mu.lock(p);
252
- yield this._fs.utimes(p, atime, mtime, cred);
253
- this._mu.unlock(p);
254
- });
211
+ async utimes(p, atime, mtime, cred) {
212
+ await this._mu.lock(p);
213
+ await this._fs.utimes(p, atime, mtime, cred);
214
+ this._mu.unlock(p);
255
215
  }
256
216
  utimesSync(p, atime, mtime, cred) {
257
217
  if (this._mu.isLocked(p)) {
@@ -259,12 +219,10 @@ export default class LockedFS {
259
219
  }
260
220
  return this._fs.utimesSync(p, atime, mtime, cred);
261
221
  }
262
- link(srcpath, dstpath, cred) {
263
- return __awaiter(this, void 0, void 0, function* () {
264
- yield this._mu.lock(srcpath);
265
- yield this._fs.link(srcpath, dstpath, cred);
266
- this._mu.unlock(srcpath);
267
- });
222
+ async link(srcpath, dstpath, cred) {
223
+ await this._mu.lock(srcpath);
224
+ await this._fs.link(srcpath, dstpath, cred);
225
+ this._mu.unlock(srcpath);
268
226
  }
269
227
  linkSync(srcpath, dstpath, cred) {
270
228
  if (this._mu.isLocked(srcpath)) {
@@ -272,12 +230,10 @@ export default class LockedFS {
272
230
  }
273
231
  return this._fs.linkSync(srcpath, dstpath, cred);
274
232
  }
275
- symlink(srcpath, dstpath, type, cred) {
276
- return __awaiter(this, void 0, void 0, function* () {
277
- yield this._mu.lock(srcpath);
278
- yield this._fs.symlink(srcpath, dstpath, type, cred);
279
- this._mu.unlock(srcpath);
280
- });
233
+ async symlink(srcpath, dstpath, type, cred) {
234
+ await this._mu.lock(srcpath);
235
+ await this._fs.symlink(srcpath, dstpath, type, cred);
236
+ this._mu.unlock(srcpath);
281
237
  }
282
238
  symlinkSync(srcpath, dstpath, type, cred) {
283
239
  if (this._mu.isLocked(srcpath)) {
@@ -285,13 +241,11 @@ export default class LockedFS {
285
241
  }
286
242
  return this._fs.symlinkSync(srcpath, dstpath, type, cred);
287
243
  }
288
- readlink(p, cred) {
289
- return __awaiter(this, void 0, void 0, function* () {
290
- yield this._mu.lock(p);
291
- const linkString = yield this._fs.readlink(p, cred);
292
- this._mu.unlock(p);
293
- return linkString;
294
- });
244
+ async readlink(p, cred) {
245
+ await this._mu.lock(p);
246
+ const linkString = await this._fs.readlink(p, cred);
247
+ this._mu.unlock(p);
248
+ return linkString;
295
249
  }
296
250
  readlinkSync(p, cred) {
297
251
  if (this._mu.isLocked(p)) {