@@ -186,7 +186,7 @@ export class FS {
186
186
} ;
187
187
} ) ;
188
188
} , fd ) . then ( ( stats ) => {
189
- callback ( undefined ! , Stats . fromObject ( stats ) ) ;
189
+ callback ( undefined ! , new Stats ( stats ) ) ;
190
190
} ) . catch ( ( ex ) => {
191
191
callback ( ex , undefined ! ) ;
192
192
} ) ;
@@ -292,7 +292,7 @@ export class FS {
292
292
} ;
293
293
} ) ;
294
294
} , path ) . then ( ( stats ) => {
295
- callback ( undefined ! , Stats . fromObject ( stats ) ) ;
295
+ callback ( undefined ! , new Stats ( stats ) ) ;
296
296
} ) . catch ( ( ex ) => {
297
297
callback ( ex , undefined ! ) ;
298
298
} ) ;
@@ -483,7 +483,7 @@ export class FS {
483
483
} ;
484
484
} ) ;
485
485
} , path ) . then ( ( stats ) => {
486
- callback ( undefined ! , Stats . fromObject ( stats ) ) ;
486
+ callback ( undefined ! , new Stats ( stats ) ) ;
487
487
} ) . catch ( ( ex ) => {
488
488
callback ( ex , undefined ! ) ;
489
489
} ) ;
@@ -652,94 +652,92 @@ class Watcher extends EventEmitter implements fs.FSWatcher {
652
652
653
653
}
654
654
655
+ interface IStats {
656
+ dev : number ;
657
+ ino : number ;
658
+ mode : number ;
659
+ nlink : number ;
660
+ uid : number ;
661
+ gid : number ;
662
+ rdev : number ;
663
+ size : number ;
664
+ blksize : number ;
665
+ blocks : number ;
666
+ atimeMs : number ;
667
+ mtimeMs : number ;
668
+ ctimeMs : number ;
669
+ birthtimeMs : number ;
670
+ atime : string ;
671
+ mtime : string ;
672
+ ctime : string ;
673
+ birthtime : string ;
674
+ _isFile : boolean ;
675
+ _isDirectory : boolean ;
676
+ _isBlockDevice : boolean ;
677
+ _isCharacterDevice : boolean ;
678
+ _isSymbolicLink : boolean ;
679
+ _isFIFO : boolean ;
680
+ _isSocket : boolean ;
681
+ }
682
+
655
683
class Stats implements fs . Stats {
656
684
657
- // tslint:disable-next-line no-any
658
- public static fromObject ( object : any ) : Stats {
659
- return new Stats ( object ) ;
660
- }
661
-
662
- // @ts -ignore
663
- public readonly dev : number ;
664
- // @ts -ignore
665
- public readonly ino : number ;
666
- // @ts -ignore
667
- public readonly mode : number ;
668
- // @ts -ignore
669
- public readonly nlink : number ;
670
- // @ts -ignore
671
- public readonly uid : number ;
672
- // @ts -ignore
673
- public readonly gid : number ;
674
- // @ts -ignore
675
- public readonly rdev : number ;
676
- // @ts -ignore
677
- public readonly size : number ;
678
- // @ts -ignore
679
- public readonly blksize : number ;
680
- // @ts -ignore
681
- public readonly blocks : number ;
682
- // @ts -ignore
683
- public readonly atimeMs : number ;
684
- // @ts -ignore
685
- public readonly mtimeMs : number ;
686
- // @ts -ignore
687
- public readonly ctimeMs : number ;
688
- // @ts -ignore
689
- public readonly birthtimeMs : number ;
690
- // @ts -ignore
691
685
public readonly atime : Date ;
692
- // @ts -ignore
693
686
public readonly mtime : Date ;
694
- // @ts -ignore
695
687
public readonly ctime : Date ;
696
- // @ts -ignore
697
688
public readonly birthtime : Date ;
698
- // @ts -ignore
699
- private readonly _isFile : boolean ;
700
- // @ts -ignore
701
- private readonly _isDirectory : boolean ;
702
- // @ts -ignore
703
- private readonly _isBlockDevice : boolean ;
704
- // @ts -ignore
705
- private readonly _isCharacterDevice : boolean ;
706
- // @ts -ignore
707
- private readonly _isSymbolicLink : boolean ;
708
- // @ts -ignore
709
- private readonly _isFIFO : boolean ;
710
- // @ts -ignore
711
- private readonly _isSocket : boolean ;
712
-
713
- private constructor ( stats : object ) {
714
- Object . assign ( this , stats ) ;
689
+
690
+ private constructor ( private readonly stats : IStats ) {
691
+ this . atime = new Date ( stats . atime ) ;
692
+ this . mtime = new Date ( stats . mtime ) ;
693
+ this . ctime = new Date ( stats . ctime ) ;
694
+ this . birthtime = new Date ( stats . birthtime ) ;
715
695
}
716
696
697
+ public get dev ( ) : number {
698
+ return this . stats . dev ;
699
+ }
700
+
701
+ public get ino ( ) : number { return this . stats . ino ; }
702
+ public get mode ( ) : number { return this . stats . mode ; }
703
+ public get nlink ( ) : number { return this . stats . nlink ; }
704
+ public get uid ( ) : number { return this . stats . uid ; }
705
+ public get gid ( ) : number { return this . stats . gid ; }
706
+ public get rdev ( ) : number { return this . stats . rdev ; }
707
+ public get size ( ) : number { return this . stats . size ; }
708
+ public get blksize ( ) : number { return this . stats . blksize ; }
709
+ public get blocks ( ) : number { return this . stats . blocks ; }
710
+ public get atimeMs ( ) : number { return this . stats . atimeMs ; }
711
+ public get mtimeMs ( ) : number { return this . stats . mtimeMs ; }
712
+ public get ctimeMs ( ) : number { return this . stats . ctimeMs ; }
713
+ public get birthtimeMs ( ) : number { return this . stats . birthtimeMs ; }
714
+
717
715
public isFile ( ) : boolean {
718
- return this . _isFile ;
716
+ return this . stats . _isFile ;
719
717
}
720
718
721
719
public isDirectory ( ) : boolean {
722
- return this . _isDirectory ;
720
+ return this . stats . _isDirectory ;
723
721
}
724
722
725
723
public isBlockDevice ( ) : boolean {
726
- return this . _isBlockDevice ;
724
+ return this . stats . _isBlockDevice ;
727
725
}
728
726
729
727
public isCharacterDevice ( ) : boolean {
730
- return this . _isCharacterDevice ;
728
+ return this . stats . _isCharacterDevice ;
731
729
}
732
730
733
731
public isSymbolicLink ( ) : boolean {
734
- return this . _isSymbolicLink ;
732
+ return this . stats . _isSymbolicLink ;
735
733
}
736
734
737
735
public isFIFO ( ) : boolean {
738
- return this . _isFIFO ;
736
+ return this . stats . _isFIFO ;
739
737
}
740
738
741
739
public isSocket ( ) : boolean {
742
- return this . _isSocket ;
740
+ return this . stats . _isSocket ;
743
741
}
744
742
745
743
public toObject ( ) : object {
0 commit comments