diff --git a/src/Stats.ts b/src/Stats.ts index a32cb12fd..48745203f 100644 --- a/src/Stats.ts +++ b/src/Stats.ts @@ -42,6 +42,14 @@ export class Stats { stats.ctimeMs = ctimeMs; stats.birthtimeMs = ctimeMs; + if (bigint) { + stats.atimeNs = BigInt(atime.getTime()) * BigInt(1000000); + stats.mtimeNs = BigInt(mtime.getTime()) * BigInt(1000000); + const ctimeNs = BigInt(ctime.getTime()) * BigInt(1000000); + stats.ctimeNs = ctimeNs; + stats.birthtimeNs = ctimeNs; + } + stats.dev = getStatNumber(0); stats.mode = getStatNumber(node.mode); stats.nlink = getStatNumber(node.nlink); @@ -68,6 +76,12 @@ export class Stats { ctimeMs: T; birthtimeMs: T; + // additional properties that exist when bigint is true + atimeNs: T extends bigint ? T : undefined; + mtimeNs: T extends bigint ? T : undefined; + ctimeNs: T extends bigint ? T : undefined; + birthtimeNs: T extends bigint ? T : undefined; + dev: T; mode: T; nlink: T; diff --git a/src/__tests__/volume.test.ts b/src/__tests__/volume.test.ts index ce53839a0..63694e109 100644 --- a/src/__tests__/volume.test.ts +++ b/src/__tests__/volume.test.ts @@ -764,6 +764,10 @@ describe('volume', () => { if (hasBigInt) { const stats = vol.lstatSync('/dojo.js', { bigint: true }); expect(typeof stats.ino).toBe('bigint'); + expect(typeof stats.atimeNs).toBe('bigint'); + expect(typeof stats.mtimeNs).toBe('bigint'); + expect(typeof stats.ctimeNs).toBe('bigint'); + expect(typeof stats.birthtimeNs).toBe('bigint'); } else { expect(() => vol.lstatSync('/dojo.js', { bigint: true })).toThrowError(); } @@ -795,6 +799,10 @@ describe('volume', () => { if (hasBigInt) { const stats = vol.statSync('/dojo.js', { bigint: true }); expect(typeof stats.ino).toBe('bigint'); + expect(typeof stats.atimeNs).toBe('bigint'); + expect(typeof stats.mtimeNs).toBe('bigint'); + expect(typeof stats.ctimeNs).toBe('bigint'); + expect(typeof stats.birthtimeNs).toBe('bigint'); } else { expect(() => vol.statSync('/dojo.js', { bigint: true })).toThrowError(); } @@ -839,6 +847,10 @@ describe('volume', () => { if (hasBigInt) { const stats = vol.fstatSync(fd, { bigint: true }); expect(typeof stats.ino).toBe('bigint'); + expect(typeof stats.atimeNs).toBe('bigint'); + expect(typeof stats.mtimeNs).toBe('bigint'); + expect(typeof stats.ctimeNs).toBe('bigint'); + expect(typeof stats.birthtimeNs).toBe('bigint'); } else { expect(() => vol.fstatSync(fd, { bigint: true })).toThrowError(); }