@@ -12,6 +12,7 @@ const {
12
12
NumberIsFinite,
13
13
MathMin,
14
14
MathRound,
15
+ ObjectDefineProperty,
15
16
ObjectIs,
16
17
ObjectSetPrototypeOf,
17
18
ReflectApply,
@@ -462,15 +463,47 @@ function BigIntStats(dev, mode, nlink, uid, gid, rdev, blksize,
462
463
this . mtimeNs = mtimeNs ;
463
464
this . ctimeNs = ctimeNs ;
464
465
this . birthtimeNs = birthtimeNs ;
465
- this . atime = dateFromMs ( this . atimeMs ) ;
466
- this . mtime = dateFromMs ( this . mtimeMs ) ;
467
- this . ctime = dateFromMs ( this . ctimeMs ) ;
468
- this . birthtime = dateFromMs ( this . birthtimeMs ) ;
469
466
}
470
467
471
468
ObjectSetPrototypeOf ( BigIntStats . prototype , StatsBase . prototype ) ;
472
469
ObjectSetPrototypeOf ( BigIntStats , StatsBase ) ;
473
470
471
+ ObjectDefineProperty ( BigIntStats . prototype , 'atime' , {
472
+ enumerable : true ,
473
+ get : function ( ) {
474
+ const value = dateFromMs ( this . atimeMs ) ;
475
+ ObjectDefineProperty ( this , 'atime' , { __proto__ : null , value } ) ;
476
+ return this . atime ;
477
+ }
478
+ } ) ;
479
+
480
+ ObjectDefineProperty ( BigIntStats . prototype , 'mtime' , {
481
+ enumerable : true ,
482
+ get : function ( ) {
483
+ const value = dateFromMs ( this . mtimeMs ) ;
484
+ ObjectDefineProperty ( this , 'mtime' , { __proto__ : null , value } ) ;
485
+ return this . mtime ;
486
+ }
487
+ } ) ;
488
+
489
+ ObjectDefineProperty ( BigIntStats . prototype , 'ctime' , {
490
+ enumerable : true ,
491
+ get : function ( ) {
492
+ const value = dateFromMs ( this . ctimeMs ) ;
493
+ ObjectDefineProperty ( this , 'ctime' , { __proto__ : null , value } ) ;
494
+ return this . ctime ;
495
+ }
496
+ } ) ;
497
+
498
+ ObjectDefineProperty ( BigIntStats . prototype , 'birthtime' , {
499
+ enumerable : true ,
500
+ get : function ( ) {
501
+ const value = dateFromMs ( this . birthtimeMs ) ;
502
+ ObjectDefineProperty ( this , 'birthtime' , { __proto__ : null , value } ) ;
503
+ return this . birthtime ;
504
+ }
505
+ } ) ;
506
+
474
507
BigIntStats . prototype . _checkModeProperty = function ( property ) {
475
508
if ( isWindows && ( property === S_IFIFO || property === S_IFBLK ||
476
509
property === S_IFSOCK ) ) {
@@ -488,15 +521,48 @@ function Stats(dev, mode, nlink, uid, gid, rdev, blksize,
488
521
this . mtimeMs = mtimeMs ;
489
522
this . ctimeMs = ctimeMs ;
490
523
this . birthtimeMs = birthtimeMs ;
491
- this . atime = dateFromMs ( atimeMs ) ;
492
- this . mtime = dateFromMs ( mtimeMs ) ;
493
- this . ctime = dateFromMs ( ctimeMs ) ;
494
- this . birthtime = dateFromMs ( birthtimeMs ) ;
495
524
}
496
525
497
526
ObjectSetPrototypeOf ( Stats . prototype , StatsBase . prototype ) ;
498
527
ObjectSetPrototypeOf ( Stats , StatsBase ) ;
499
528
529
+ ObjectDefineProperty ( Stats . prototype , 'atime' , {
530
+ enumerable : true ,
531
+ get : function ( ) {
532
+ const value = dateFromMs ( this . atimeMs ) ;
533
+ ObjectDefineProperty ( this , 'atime' , { __proto__ : null , value } ) ;
534
+ return this . atime ;
535
+ }
536
+ } ) ;
537
+
538
+ ObjectDefineProperty ( Stats . prototype , 'mtime' , {
539
+ enumerable : true ,
540
+ get : function ( ) {
541
+ console . log ( 'getter called mtime' )
542
+ const value = dateFromMs ( this . mtimeMs ) ;
543
+ ObjectDefineProperty ( this , 'mtime' , { __proto__ : null , value } ) ;
544
+ return this . mtime ;
545
+ }
546
+ } ) ;
547
+
548
+ ObjectDefineProperty ( Stats . prototype , 'ctime' , {
549
+ enumerable : true ,
550
+ get : function ( ) {
551
+ const value = dateFromMs ( this . ctimeMs ) ;
552
+ ObjectDefineProperty ( this , 'ctime' , { __proto__ : null , value } ) ;
553
+ return this . ctime ;
554
+ }
555
+ } ) ;
556
+
557
+ ObjectDefineProperty ( Stats . prototype , 'birthtime' , {
558
+ enumerable : true ,
559
+ get : function ( ) {
560
+ const value = dateFromMs ( this . birthtimeMs ) ;
561
+ ObjectDefineProperty ( this , 'birthtime' , { __proto__ : null , value } ) ;
562
+ return this . birthtime ;
563
+ }
564
+ } ) ;
565
+
500
566
// HACK: Workaround for https://github.com/standard-things/esm/issues/821.
501
567
// TODO(ronag): Remove this as soon as `esm` publishes a fixed version.
502
568
Stats . prototype . isFile = StatsBase . prototype . isFile ;
0 commit comments