Comparing version 3.5.0 to 3.5.1
@@ -12,13 +12,27 @@ /// <reference types="node" /> | ||
ino: number; | ||
uid: number; | ||
gid: number; | ||
atime: Date; | ||
mtime: Date; | ||
ctime: Date; | ||
private _uid; | ||
private _gid; | ||
private _atime; | ||
private _mtime; | ||
private _ctime; | ||
buf: Buffer; | ||
perm: number; | ||
private _perm; | ||
mode: number; | ||
nlink: number; | ||
private _nlink; | ||
symlink: string[]; | ||
constructor(ino: number, perm?: number); | ||
set ctime(ctime: Date); | ||
get ctime(): Date; | ||
set uid(uid: number); | ||
get uid(): number; | ||
set gid(gid: number); | ||
get gid(): number; | ||
set atime(atime: Date); | ||
get atime(): Date; | ||
set mtime(mtime: Date); | ||
get mtime(): Date; | ||
set perm(perm: number); | ||
get perm(): number; | ||
set nlink(nlink: number); | ||
get nlink(): number; | ||
getString(encoding?: string): string; | ||
@@ -25,0 +39,0 @@ setString(str: string): void; |
123
lib/node.js
@@ -37,12 +37,12 @@ "use strict"; | ||
// User ID and group ID. | ||
_this.uid = getuid(); | ||
_this.gid = getgid(); | ||
_this.atime = new Date(); | ||
_this.mtime = new Date(); | ||
_this.ctime = new Date(); | ||
_this.perm = 438; // Permissions `chmod`, `fchmod` | ||
_this._uid = getuid(); | ||
_this._gid = getgid(); | ||
_this._atime = new Date(); | ||
_this._mtime = new Date(); | ||
_this._ctime = new Date(); | ||
_this._perm = 438; // Permissions `chmod`, `fchmod` | ||
_this.mode = S_IFREG; // S_IFDIR, S_IFREG, etc.. (file by default?) | ||
// Number of hard links pointing at this Node. | ||
_this.nlink = 1; | ||
_this.perm = perm; | ||
_this._nlink = 1; | ||
_this._perm = perm; | ||
_this.mode |= perm; | ||
@@ -52,4 +52,81 @@ _this.ino = ino; | ||
} | ||
Object.defineProperty(Node.prototype, "ctime", { | ||
get: function () { | ||
return this._ctime; | ||
}, | ||
set: function (ctime) { | ||
this._ctime = ctime; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Node.prototype, "uid", { | ||
get: function () { | ||
return this._uid; | ||
}, | ||
set: function (uid) { | ||
this._uid = uid; | ||
this.ctime = new Date(); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Node.prototype, "gid", { | ||
get: function () { | ||
return this._gid; | ||
}, | ||
set: function (gid) { | ||
this._gid = gid; | ||
this.ctime = new Date(); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Node.prototype, "atime", { | ||
get: function () { | ||
return this._atime; | ||
}, | ||
set: function (atime) { | ||
this._atime = atime; | ||
this.ctime = new Date(); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Node.prototype, "mtime", { | ||
get: function () { | ||
return this._mtime; | ||
}, | ||
set: function (mtime) { | ||
this._mtime = mtime; | ||
this.ctime = new Date(); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Node.prototype, "perm", { | ||
get: function () { | ||
return this._perm; | ||
}, | ||
set: function (perm) { | ||
this._perm = perm; | ||
this.ctime = new Date(); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Node.prototype, "nlink", { | ||
get: function () { | ||
return this._nlink; | ||
}, | ||
set: function (nlink) { | ||
this._nlink = nlink; | ||
this.ctime = new Date(); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Node.prototype.getString = function (encoding) { | ||
if (encoding === void 0) { encoding = 'utf8'; } | ||
this.atime = new Date(); | ||
return this.getBuffer().toString(encoding); | ||
@@ -63,2 +140,3 @@ }; | ||
Node.prototype.getBuffer = function () { | ||
this.atime = new Date(); | ||
if (!this.buf) | ||
@@ -121,2 +199,3 @@ this.setBuffer((0, buffer_1.bufferAllocUnsafe)(0)); | ||
if (pos === void 0) { pos = 0; } | ||
this.atime = new Date(); | ||
if (!this.buf) | ||
@@ -251,5 +330,8 @@ this.buf = (0, buffer_1.bufferAllocUnsafe)(0); | ||
this._steps = val; | ||
for (var _i = 0, _a = Object.values(this.children); _i < _a.length; _i++) { | ||
var child = _a[_i]; | ||
child === null || child === void 0 ? void 0 : child.syncSteps(); | ||
for (var _i = 0, _a = Object.entries(this.children); _i < _a.length; _i++) { | ||
var _b = _a[_i], child = _b[0], link = _b[1]; | ||
if (child === '.' || child === '..') { | ||
continue; | ||
} | ||
link === null || link === void 0 ? void 0 : link.syncSteps(); | ||
} | ||
@@ -272,6 +354,4 @@ }, | ||
if (node.isDirectory()) { | ||
// link.setChild('.', link); | ||
// link.getNode().nlink++; | ||
// link.setChild('..', this); | ||
// this.getNode().nlink++; | ||
link.children['.'] = link; | ||
link.getNode().nlink++; | ||
} | ||
@@ -286,2 +366,8 @@ this.setChild(name, link); | ||
this.length++; | ||
var node = link.getNode(); | ||
if (node.isDirectory()) { | ||
link.children['..'] = this; | ||
this.getNode().nlink++; | ||
} | ||
this.getNode().mtime = new Date(); | ||
this.emit('child:add', link, this); | ||
@@ -291,7 +377,14 @@ return link; | ||
Link.prototype.deleteChild = function (link) { | ||
var node = link.getNode(); | ||
if (node.isDirectory()) { | ||
delete link.children['..']; | ||
this.getNode().nlink--; | ||
} | ||
delete this.children[link.getName()]; | ||
this.length--; | ||
this.getNode().mtime = new Date(); | ||
this.emit('child:delete', link, this); | ||
}; | ||
Link.prototype.getChild = function (name) { | ||
this.getNode().mtime = new Date(); | ||
if (Object.hasOwnProperty.call(this.children, name)) { | ||
@@ -298,0 +391,0 @@ return this.children[name]; |
{ | ||
"name": "memfs", | ||
"version": "3.5.0", | ||
"version": "3.5.1", | ||
"description": "In-memory file-system with Node's fs API.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
186053
4656