| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e710036 commit ae6c704
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -196,81 +196,13 @@ function Stats( | |||
| 196 | 196 | this.ino = ino; | |
| 197 | 197 | this.size = size; | |
| 198 | 198 | this.blocks = blocks; | |
| 199 | - this._atim_msec = atim_msec; | ||
| 200 | - this._mtim_msec = mtim_msec; | ||
| 201 | - this._ctim_msec = ctim_msec; | ||
| 202 | - this._birthtim_msec = birthtim_msec; | ||
| 199 | + this.atime = new Date(atim_msec + 0.5); | ||
| 200 | + this.mtime = new Date(mtim_msec + 0.5); | ||
| 201 | + this.ctime = new Date(ctim_msec + 0.5); | ||
| 202 | + this.birthtime = new Date(birthtim_msec + 0.5); | ||
| 203 | 203 | } | |
| 204 | 204 | fs.Stats = Stats; | |
| 205 | 205 | ||
| 206 | - // defining the properties in this fashion (explicitly with no loop or factory) | ||
| 207 | - // has been shown to be the most performant on V8 contemp. | ||
| 208 | - // Ref: https://github.com/nodejs/node/pull/12818 | ||
| 209 | - // + 0.5 is added to the Dates to protect values from being rounded down | ||
| 210 | - // Ref: https://github.com/nodejs/node/pull/12607 | ||
| 211 | - Object.defineProperties(Stats.prototype, { | ||
| 212 | - atime: { | ||
| 213 | - configurable: true, | ||
| 214 | - enumerable: true, | ||
| 215 | - get() { | ||
| 216 | - return this._atime !== undefined ? | ||
| 217 | - this._atime : | ||
| 218 | - (this._atime = new Date(this._atim_msec + 0.5)); | ||
| 219 | - }, | ||
| 220 | - set(value) { return this._atime = value; } | ||
| 221 | - }, | ||
| 222 | - mtime: { | ||
| 223 | - configurable: true, | ||
| 224 | - enumerable: true, | ||
| 225 | - get() { | ||
| 226 | - return this._mtime !== undefined ? | ||
| 227 | - this._mtime : | ||
| 228 | - (this._mtime = new Date(this._mtim_msec + 0.5)); | ||
| 229 | - }, | ||
| 230 | - set(value) { return this._mtime = value; } | ||
| 231 | - }, | ||
| 232 | - ctime: { | ||
| 233 | - configurable: true, | ||
| 234 | - enumerable: true, | ||
| 235 | - get() { | ||
| 236 | - return this._ctime !== undefined ? | ||
| 237 | - this._ctime : | ||
| 238 | - (this._ctime = new Date(this._ctim_msec + 0.5)); | ||
| 239 | - }, | ||
| 240 | - set(value) { return this._ctime = value; } | ||
| 241 | - }, | ||
| 242 | - birthtime: { | ||
| 243 | - configurable: true, | ||
| 244 | - enumerable: true, | ||
| 245 | - get() { | ||
| 246 | - return this._birthtime !== undefined ? | ||
| 247 | - this._birthtime : | ||
| 248 | - (this._birthtime = new Date(this._birthtim_msec + 0.5)); | ||
| 249 | - }, | ||
| 250 | - set(value) { return this._birthtime = value; } | ||
| 251 | - }, | ||
| 252 | - }); | ||
| 253 | - | ||
| 254 | - Stats.prototype.toJSON = function toJSON() { | ||
| 255 | - return { | ||
| 256 | - dev: this.dev, | ||
| 257 | - mode: this.mode, | ||
| 258 | - nlink: this.nlink, | ||
| 259 | - uid: this.uid, | ||
| 260 | - gid: this.gid, | ||
| 261 | - rdev: this.rdev, | ||
| 262 | - blksize: this.blksize, | ||
| 263 | - ino: this.ino, | ||
| 264 | - size: this.size, | ||
| 265 | - blocks: this.blocks, | ||
| 266 | - atime: this.atime, | ||
| 267 | - ctime: this.ctime, | ||
| 268 | - mtime: this.mtime, | ||
| 269 | - birthtime: this.birthtime | ||
| 270 | - }; | ||
| 271 | - }; | ||
| 272 | - | ||
| 273 | - | ||
| 274 | 206 | Stats.prototype._checkModeProperty = function(property) { | |
| 275 | 207 | return ((this.mode & S_IFMT) === property); | |
| 276 | 208 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -98,27 +98,5 @@ fs.stat(__filename, common.mustCall(function(err, s) { | |||
| 98 | 98 | console.log(`isSymbolicLink: ${JSON.stringify(s.isSymbolicLink())}`); | |
| 99 | 99 | assert.strictEqual(false, s.isSymbolicLink()); | |
| 100 | 100 | ||
| 101 | - assert.ok(s.atime instanceof Date); | ||
| 102 | 101 | assert.ok(s.mtime instanceof Date); | |
| 103 | - assert.ok(s.ctime instanceof Date); | ||
| 104 | - assert.ok(s.birthtime instanceof Date); | ||
| 105 | - })); | ||
| 106 | - | ||
| 107 | - fs.stat(__filename, common.mustCall(function(err, s) { | ||
| 108 | - const json = JSON.parse(JSON.stringify(s)); | ||
| 109 | - const keys = [ | ||
| 110 | - 'dev', 'mode', 'nlink', 'uid', | ||
| 111 | - 'gid', 'rdev', 'ino', | ||
| 112 | - 'size', 'atime', 'mtime', | ||
| 113 | - 'ctime', 'birthtime' | ||
| 114 | - ]; | ||
| 115 | - if (!common.isWindows) { | ||
| 116 | - keys.push('blocks', 'blksize'); | ||
| 117 | - } | ||
| 118 | - keys.forEach(function(k) { | ||
| 119 | - assert.ok( | ||
| 120 | - json[k] !== undefined && json[k] !== null, | ||
| 121 | - k + ' should not be null or undefined' | ||
| 122 | - ); | ||
| 123 | - }); | ||
| 124 | 102 | })); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments