memfs 3.5.3 → 4.0.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.
package/lib/node.js CHANGED
@@ -1,213 +1,160 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.File = exports.Link = exports.Node = exports.SEP = void 0;
19
- var process_1 = require("./process");
20
- var buffer_1 = require("./internal/buffer");
21
- var constants_1 = require("./constants");
22
- var events_1 = require("events");
23
- var Stats_1 = require("./Stats");
24
- var S_IFMT = constants_1.constants.S_IFMT, S_IFDIR = constants_1.constants.S_IFDIR, S_IFREG = constants_1.constants.S_IFREG, S_IFLNK = constants_1.constants.S_IFLNK, O_APPEND = constants_1.constants.O_APPEND;
25
- var getuid = function () { 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; };
26
- var getgid = function () { 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; };
4
+ const process_1 = require("./process");
5
+ const buffer_1 = require("./internal/buffer");
6
+ const constants_1 = require("./constants");
7
+ const events_1 = require("events");
8
+ const Stats_1 = require("./Stats");
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; };
27
12
  exports.SEP = '/';
28
13
  /**
29
14
  * Node in a file system (like i-node, v-node).
30
15
  */
31
- var Node = /** @class */ (function (_super) {
32
- __extends(Node, _super);
33
- function Node(ino, perm) {
34
- if (perm === void 0) { perm = 438; }
35
- var _this = _super.call(this) || this;
16
+ class Node extends events_1.EventEmitter {
17
+ constructor(ino, perm = 0o666) {
18
+ super();
36
19
  // User ID and group ID.
37
- _this._uid = getuid();
38
- _this._gid = getgid();
39
- _this._atime = new Date();
40
- _this._mtime = new Date();
41
- _this._ctime = new Date();
42
- _this._perm = 438; // Permissions `chmod`, `fchmod`
43
- _this.mode = S_IFREG; // S_IFDIR, S_IFREG, etc.. (file by default?)
20
+ this._uid = getuid();
21
+ this._gid = getgid();
22
+ this._atime = new Date();
23
+ this._mtime = new Date();
24
+ this._ctime = new Date();
25
+ this._perm = 0o666; // Permissions `chmod`, `fchmod`
26
+ this.mode = S_IFREG; // S_IFDIR, S_IFREG, etc.. (file by default?)
44
27
  // Number of hard links pointing at this Node.
45
- _this._nlink = 1;
46
- _this._perm = perm;
47
- _this.mode |= perm;
48
- _this.ino = ino;
49
- return _this;
50
- }
51
- Object.defineProperty(Node.prototype, "ctime", {
52
- get: function () {
53
- return this._ctime;
54
- },
55
- set: function (ctime) {
56
- this._ctime = ctime;
57
- },
58
- enumerable: false,
59
- configurable: true
60
- });
61
- Object.defineProperty(Node.prototype, "uid", {
62
- get: function () {
63
- return this._uid;
64
- },
65
- set: function (uid) {
66
- this._uid = uid;
67
- this.ctime = new Date();
68
- },
69
- enumerable: false,
70
- configurable: true
71
- });
72
- Object.defineProperty(Node.prototype, "gid", {
73
- get: function () {
74
- return this._gid;
75
- },
76
- set: function (gid) {
77
- this._gid = gid;
78
- this.ctime = new Date();
79
- },
80
- enumerable: false,
81
- configurable: true
82
- });
83
- Object.defineProperty(Node.prototype, "atime", {
84
- get: function () {
85
- return this._atime;
86
- },
87
- set: function (atime) {
88
- this._atime = atime;
89
- this.ctime = new Date();
90
- },
91
- enumerable: false,
92
- configurable: true
93
- });
94
- Object.defineProperty(Node.prototype, "mtime", {
95
- get: function () {
96
- return this._mtime;
97
- },
98
- set: function (mtime) {
99
- this._mtime = mtime;
100
- this.ctime = new Date();
101
- },
102
- enumerable: false,
103
- configurable: true
104
- });
105
- Object.defineProperty(Node.prototype, "perm", {
106
- get: function () {
107
- return this._perm;
108
- },
109
- set: function (perm) {
110
- this._perm = perm;
111
- this.ctime = new Date();
112
- },
113
- enumerable: false,
114
- configurable: true
115
- });
116
- Object.defineProperty(Node.prototype, "nlink", {
117
- get: function () {
118
- return this._nlink;
119
- },
120
- set: function (nlink) {
121
- this._nlink = nlink;
122
- this.ctime = new Date();
123
- },
124
- enumerable: false,
125
- configurable: true
126
- });
127
- Node.prototype.getString = function (encoding) {
128
- if (encoding === void 0) { encoding = 'utf8'; }
28
+ this._nlink = 1;
29
+ this._perm = perm;
30
+ this.mode |= perm;
31
+ this.ino = ino;
32
+ }
33
+ set ctime(ctime) {
34
+ this._ctime = ctime;
35
+ }
36
+ get ctime() {
37
+ return this._ctime;
38
+ }
39
+ set uid(uid) {
40
+ this._uid = uid;
41
+ this.ctime = new Date();
42
+ }
43
+ get uid() {
44
+ return this._uid;
45
+ }
46
+ set gid(gid) {
47
+ this._gid = gid;
48
+ this.ctime = new Date();
49
+ }
50
+ get gid() {
51
+ return this._gid;
52
+ }
53
+ set atime(atime) {
54
+ this._atime = atime;
55
+ this.ctime = new Date();
56
+ }
57
+ get atime() {
58
+ return this._atime;
59
+ }
60
+ set mtime(mtime) {
61
+ this._mtime = mtime;
62
+ this.ctime = new Date();
63
+ }
64
+ get mtime() {
65
+ return this._mtime;
66
+ }
67
+ set perm(perm) {
68
+ this._perm = perm;
69
+ this.ctime = new Date();
70
+ }
71
+ get perm() {
72
+ return this._perm;
73
+ }
74
+ set nlink(nlink) {
75
+ this._nlink = nlink;
76
+ this.ctime = new Date();
77
+ }
78
+ get nlink() {
79
+ return this._nlink;
80
+ }
81
+ getString(encoding = 'utf8') {
129
82
  this.atime = new Date();
130
83
  return this.getBuffer().toString(encoding);
131
- };
132
- Node.prototype.setString = function (str) {
84
+ }
85
+ setString(str) {
133
86
  // this.setBuffer(bufferFrom(str, 'utf8'));
134
87
  this.buf = (0, buffer_1.bufferFrom)(str, 'utf8');
135
88
  this.touch();
136
- };
137
- Node.prototype.getBuffer = function () {
89
+ }
90
+ getBuffer() {
138
91
  this.atime = new Date();
139
92
  if (!this.buf)
140
93
  this.setBuffer((0, buffer_1.bufferAllocUnsafe)(0));
141
94
  return (0, buffer_1.bufferFrom)(this.buf); // Return a copy.
142
- };
143
- Node.prototype.setBuffer = function (buf) {
95
+ }
96
+ setBuffer(buf) {
144
97
  this.buf = (0, buffer_1.bufferFrom)(buf); // Creates a copy of data.
145
98
  this.touch();
146
- };
147
- Node.prototype.getSize = function () {
99
+ }
100
+ getSize() {
148
101
  return this.buf ? this.buf.length : 0;
149
- };
150
- Node.prototype.setModeProperty = function (property) {
102
+ }
103
+ setModeProperty(property) {
151
104
  this.mode = (this.mode & ~S_IFMT) | property;
152
- };
153
- Node.prototype.setIsFile = function () {
105
+ }
106
+ setIsFile() {
154
107
  this.setModeProperty(S_IFREG);
155
- };
156
- Node.prototype.setIsDirectory = function () {
108
+ }
109
+ setIsDirectory() {
157
110
  this.setModeProperty(S_IFDIR);
158
- };
159
- Node.prototype.setIsSymlink = function () {
111
+ }
112
+ setIsSymlink() {
160
113
  this.setModeProperty(S_IFLNK);
161
- };
162
- Node.prototype.isFile = function () {
114
+ }
115
+ isFile() {
163
116
  return (this.mode & S_IFMT) === S_IFREG;
164
- };
165
- Node.prototype.isDirectory = function () {
117
+ }
118
+ isDirectory() {
166
119
  return (this.mode & S_IFMT) === S_IFDIR;
167
- };
168
- Node.prototype.isSymlink = function () {
120
+ }
121
+ isSymlink() {
169
122
  // return !!this.symlink;
170
123
  return (this.mode & S_IFMT) === S_IFLNK;
171
- };
172
- Node.prototype.makeSymlink = function (steps) {
124
+ }
125
+ makeSymlink(steps) {
173
126
  this.symlink = steps;
174
127
  this.setIsSymlink();
175
- };
176
- Node.prototype.write = function (buf, off, len, pos) {
177
- if (off === void 0) { off = 0; }
178
- if (len === void 0) { len = buf.length; }
179
- if (pos === void 0) { pos = 0; }
128
+ }
129
+ write(buf, off = 0, len = buf.length, pos = 0) {
180
130
  if (!this.buf)
181
131
  this.buf = (0, buffer_1.bufferAllocUnsafe)(0);
182
132
  if (pos + len > this.buf.length) {
183
- var newBuf = (0, buffer_1.bufferAllocUnsafe)(pos + len);
133
+ const newBuf = (0, buffer_1.bufferAllocUnsafe)(pos + len);
184
134
  this.buf.copy(newBuf, 0, 0, this.buf.length);
185
135
  this.buf = newBuf;
186
136
  }
187
137
  buf.copy(this.buf, pos, off, off + len);
188
138
  this.touch();
189
139
  return len;
190
- };
140
+ }
191
141
  // Returns the number of bytes read.
192
- Node.prototype.read = function (buf, off, len, pos) {
193
- if (off === void 0) { off = 0; }
194
- if (len === void 0) { len = buf.byteLength; }
195
- if (pos === void 0) { pos = 0; }
142
+ read(buf, off = 0, len = buf.byteLength, pos = 0) {
196
143
  this.atime = new Date();
197
144
  if (!this.buf)
198
145
  this.buf = (0, buffer_1.bufferAllocUnsafe)(0);
199
- var actualLen = len;
146
+ let actualLen = len;
200
147
  if (actualLen > buf.byteLength) {
201
148
  actualLen = buf.byteLength;
202
149
  }
203
150
  if (actualLen + pos > this.buf.length) {
204
151
  actualLen = this.buf.length - pos;
205
152
  }
206
- this.buf.copy(buf, off, pos, pos + actualLen);
153
+ const buf2 = buf instanceof Buffer ? buf : Buffer.from(buf.buffer);
154
+ this.buf.copy(buf2, off, pos, pos + actualLen);
207
155
  return actualLen;
208
- };
209
- Node.prototype.truncate = function (len) {
210
- if (len === void 0) { len = 0; }
156
+ }
157
+ truncate(len = 0) {
211
158
  if (!len)
212
159
  this.buf = (0, buffer_1.bufferAllocUnsafe)(0);
213
160
  else {
@@ -217,31 +164,29 @@ var Node = /** @class */ (function (_super) {
217
164
  this.buf = this.buf.slice(0, len);
218
165
  }
219
166
  else {
220
- var buf = (0, buffer_1.bufferAllocUnsafe)(len);
167
+ const buf = (0, buffer_1.bufferAllocUnsafe)(len);
221
168
  this.buf.copy(buf);
222
169
  buf.fill(0, this.buf.length);
223
170
  this.buf = buf;
224
171
  }
225
172
  }
226
173
  this.touch();
227
- };
228
- Node.prototype.chmod = function (perm) {
174
+ }
175
+ chmod(perm) {
229
176
  this.perm = perm;
230
- this.mode = (this.mode & ~511) | perm;
177
+ this.mode = (this.mode & ~0o777) | perm;
231
178
  this.touch();
232
- };
233
- Node.prototype.chown = function (uid, gid) {
179
+ }
180
+ chown(uid, gid) {
234
181
  this.uid = uid;
235
182
  this.gid = gid;
236
183
  this.touch();
237
- };
238
- Node.prototype.touch = function () {
184
+ }
185
+ touch() {
239
186
  this.mtime = new Date();
240
187
  this.emit('change', this);
241
- };
242
- Node.prototype.canRead = function (uid, gid) {
243
- if (uid === void 0) { uid = getuid(); }
244
- if (gid === void 0) { gid = getgid(); }
188
+ }
189
+ canRead(uid = getuid(), gid = getgid()) {
245
190
  if (this.perm & 4 /* S.IROTH */) {
246
191
  return true;
247
192
  }
@@ -256,10 +201,8 @@ var Node = /** @class */ (function (_super) {
256
201
  }
257
202
  }
258
203
  return false;
259
- };
260
- Node.prototype.canWrite = function (uid, gid) {
261
- if (uid === void 0) { uid = getuid(); }
262
- if (gid === void 0) { gid = getgid(); }
204
+ }
205
+ canWrite(uid = getuid(), gid = getgid()) {
263
206
  if (this.perm & 2 /* S.IWOTH */) {
264
207
  return true;
265
208
  }
@@ -274,11 +217,11 @@ var Node = /** @class */ (function (_super) {
274
217
  }
275
218
  }
276
219
  return false;
277
- };
278
- Node.prototype.del = function () {
220
+ }
221
+ del() {
279
222
  this.emit('delete', this);
280
- };
281
- Node.prototype.toJSON = function () {
223
+ }
224
+ toJSON() {
282
225
  return {
283
226
  ino: this.ino,
284
227
  uid: this.uid,
@@ -292,58 +235,49 @@ var Node = /** @class */ (function (_super) {
292
235
  symlink: this.symlink,
293
236
  data: this.getString(),
294
237
  };
295
- };
296
- return Node;
297
- }(events_1.EventEmitter));
238
+ }
239
+ }
298
240
  exports.Node = Node;
299
241
  /**
300
242
  * Represents a hard link that points to an i-node `node`.
301
243
  */
302
- var Link = /** @class */ (function (_super) {
303
- __extends(Link, _super);
304
- function Link(vol, parent, name) {
305
- var _this = _super.call(this) || this;
306
- _this.children = {};
244
+ class Link extends events_1.EventEmitter {
245
+ get steps() {
246
+ return this._steps;
247
+ }
248
+ // Recursively sync children steps, e.g. in case of dir rename
249
+ set steps(val) {
250
+ this._steps = val;
251
+ for (const [child, link] of Object.entries(this.children)) {
252
+ if (child === '.' || child === '..') {
253
+ continue;
254
+ }
255
+ link === null || link === void 0 ? void 0 : link.syncSteps();
256
+ }
257
+ }
258
+ constructor(vol, parent, name) {
259
+ super();
260
+ this.children = {};
307
261
  // Path to this node as Array: ['usr', 'bin', 'node'].
308
- _this._steps = [];
262
+ this._steps = [];
309
263
  // "i-node" number of the node.
310
- _this.ino = 0;
264
+ this.ino = 0;
311
265
  // Number of children.
312
- _this.length = 0;
313
- _this.vol = vol;
314
- _this.parent = parent;
315
- _this.name = name;
316
- _this.syncSteps();
317
- return _this;
318
- }
319
- Object.defineProperty(Link.prototype, "steps", {
320
- get: function () {
321
- return this._steps;
322
- },
323
- // Recursively sync children steps, e.g. in case of dir rename
324
- set: function (val) {
325
- this._steps = val;
326
- for (var _i = 0, _a = Object.entries(this.children); _i < _a.length; _i++) {
327
- var _b = _a[_i], child = _b[0], link = _b[1];
328
- if (child === '.' || child === '..') {
329
- continue;
330
- }
331
- link === null || link === void 0 ? void 0 : link.syncSteps();
332
- }
333
- },
334
- enumerable: false,
335
- configurable: true
336
- });
337
- Link.prototype.setNode = function (node) {
266
+ this.length = 0;
267
+ this.vol = vol;
268
+ this.parent = parent;
269
+ this.name = name;
270
+ this.syncSteps();
271
+ }
272
+ setNode(node) {
338
273
  this.node = node;
339
274
  this.ino = node.ino;
340
- };
341
- Link.prototype.getNode = function () {
275
+ }
276
+ getNode() {
342
277
  return this.node;
343
- };
344
- Link.prototype.createChild = function (name, node) {
345
- if (node === void 0) { node = this.vol.createNode(); }
346
- var link = new Link(this.vol, this, name);
278
+ }
279
+ createChild(name, node = this.vol.createNode()) {
280
+ const link = new Link(this.vol, this, name);
347
281
  link.setNode(node);
348
282
  if (node.isDirectory()) {
349
283
  link.children['.'] = link;
@@ -351,13 +285,12 @@ var Link = /** @class */ (function (_super) {
351
285
  }
352
286
  this.setChild(name, link);
353
287
  return link;
354
- };
355
- Link.prototype.setChild = function (name, link) {
356
- if (link === void 0) { link = new Link(this.vol, this, name); }
288
+ }
289
+ setChild(name, link = new Link(this.vol, this, name)) {
357
290
  this.children[name] = link;
358
291
  link.parent = this;
359
292
  this.length++;
360
- var node = link.getNode();
293
+ const node = link.getNode();
361
294
  if (node.isDirectory()) {
362
295
  link.children['..'] = this;
363
296
  this.getNode().nlink++;
@@ -365,9 +298,9 @@ var Link = /** @class */ (function (_super) {
365
298
  this.getNode().mtime = new Date();
366
299
  this.emit('child:add', link, this);
367
300
  return link;
368
- };
369
- Link.prototype.deleteChild = function (link) {
370
- var node = link.getNode();
301
+ }
302
+ deleteChild(link) {
303
+ const node = link.getNode();
371
304
  if (node.isDirectory()) {
372
305
  delete link.children['..'];
373
306
  this.getNode().nlink--;
@@ -376,19 +309,19 @@ var Link = /** @class */ (function (_super) {
376
309
  this.length--;
377
310
  this.getNode().mtime = new Date();
378
311
  this.emit('child:delete', link, this);
379
- };
380
- Link.prototype.getChild = function (name) {
312
+ }
313
+ getChild(name) {
381
314
  this.getNode().mtime = new Date();
382
315
  if (Object.hasOwnProperty.call(this.children, name)) {
383
316
  return this.children[name];
384
317
  }
385
- };
386
- Link.prototype.getPath = function () {
318
+ }
319
+ getPath() {
387
320
  return this.steps.join(exports.SEP);
388
- };
389
- Link.prototype.getName = function () {
321
+ }
322
+ getName() {
390
323
  return this.steps[this.steps.length - 1];
391
- };
324
+ }
392
325
  // del() {
393
326
  // const parent = this.parent;
394
327
  // if(parent) {
@@ -405,36 +338,33 @@ var Link = /** @class */ (function (_super) {
405
338
  *
406
339
  * @return {Link|null}
407
340
  */
408
- Link.prototype.walk = function (steps, stop, i) {
409
- if (stop === void 0) { stop = steps.length; }
410
- if (i === void 0) { i = 0; }
341
+ walk(steps, stop = steps.length, i = 0) {
411
342
  if (i >= steps.length)
412
343
  return this;
413
344
  if (i >= stop)
414
345
  return this;
415
- var step = steps[i];
416
- var link = this.getChild(step);
346
+ const step = steps[i];
347
+ const link = this.getChild(step);
417
348
  if (!link)
418
349
  return null;
419
350
  return link.walk(steps, stop, i + 1);
420
- };
421
- Link.prototype.toJSON = function () {
351
+ }
352
+ toJSON() {
422
353
  return {
423
354
  steps: this.steps,
424
355
  ino: this.ino,
425
356
  children: Object.keys(this.children),
426
357
  };
427
- };
428
- Link.prototype.syncSteps = function () {
358
+ }
359
+ syncSteps() {
429
360
  this.steps = this.parent ? this.parent.steps.concat([this.name]) : [this.name];
430
- };
431
- return Link;
432
- }(events_1.EventEmitter));
361
+ }
362
+ }
433
363
  exports.Link = Link;
434
364
  /**
435
365
  * Represents an open file (file descriptor) that points to a `Link` (Hard-link) and a `Node`.
436
366
  */
437
- var File = /** @class */ (function () {
367
+ class File {
438
368
  /**
439
369
  * Open a Link-Node pair. `node` is provided separately as that might be a different node
440
370
  * rather the one `link` points to, because it might be a symlink.
@@ -443,68 +373,58 @@ var File = /** @class */ (function () {
443
373
  * @param flags
444
374
  * @param fd
445
375
  */
446
- function File(link, node, flags, fd) {
447
- /**
448
- * A cursor/offset position in a file, where data will be written on write.
449
- * User can "seek" this position.
450
- */
451
- this.position = 0;
376
+ constructor(link, node, flags, fd) {
452
377
  this.link = link;
453
378
  this.node = node;
454
379
  this.flags = flags;
455
380
  this.fd = fd;
381
+ this.position = 0;
382
+ if (this.flags & O_APPEND)
383
+ this.position = this.getSize();
456
384
  }
457
- File.prototype.getString = function (encoding) {
458
- if (encoding === void 0) { encoding = 'utf8'; }
385
+ getString(encoding = 'utf8') {
459
386
  return this.node.getString();
460
- };
461
- File.prototype.setString = function (str) {
387
+ }
388
+ setString(str) {
462
389
  this.node.setString(str);
463
- };
464
- File.prototype.getBuffer = function () {
390
+ }
391
+ getBuffer() {
465
392
  return this.node.getBuffer();
466
- };
467
- File.prototype.setBuffer = function (buf) {
393
+ }
394
+ setBuffer(buf) {
468
395
  this.node.setBuffer(buf);
469
- };
470
- File.prototype.getSize = function () {
396
+ }
397
+ getSize() {
471
398
  return this.node.getSize();
472
- };
473
- File.prototype.truncate = function (len) {
399
+ }
400
+ truncate(len) {
474
401
  this.node.truncate(len);
475
- };
476
- File.prototype.seekTo = function (position) {
402
+ }
403
+ seekTo(position) {
477
404
  this.position = position;
478
- };
479
- File.prototype.stats = function () {
405
+ }
406
+ stats() {
480
407
  return Stats_1.default.build(this.node);
481
- };
482
- File.prototype.write = function (buf, offset, length, position) {
483
- if (offset === void 0) { offset = 0; }
484
- if (length === void 0) { length = buf.length; }
408
+ }
409
+ write(buf, offset = 0, length = buf.length, position) {
485
410
  if (typeof position !== 'number')
486
411
  position = this.position;
487
- if (this.flags & O_APPEND)
488
- position = this.getSize();
489
- var bytes = this.node.write(buf, offset, length, position);
412
+ const bytes = this.node.write(buf, offset, length, position);
490
413
  this.position = position + bytes;
491
414
  return bytes;
492
- };
493
- File.prototype.read = function (buf, offset, length, position) {
494
- if (offset === void 0) { offset = 0; }
495
- if (length === void 0) { length = buf.byteLength; }
415
+ }
416
+ read(buf, offset = 0, length = buf.byteLength, position) {
496
417
  if (typeof position !== 'number')
497
418
  position = this.position;
498
- var bytes = this.node.read(buf, offset, length, position);
419
+ const bytes = this.node.read(buf, offset, length, position);
499
420
  this.position = position + bytes;
500
421
  return bytes;
501
- };
502
- File.prototype.chmod = function (perm) {
422
+ }
423
+ chmod(perm) {
503
424
  this.node.chmod(perm);
504
- };
505
- File.prototype.chown = function (uid, gid) {
425
+ }
426
+ chown(uid, gid) {
506
427
  this.node.chown(uid, gid);
507
- };
508
- return File;
509
- }());
428
+ }
429
+ }
510
430
  exports.File = File;