From 0bc5e7eb878c40e127d60ddb88727e1923647f23 Mon Sep 17 00:00:00 2001 From: James Prevett Date: Thu, 19 Dec 2024 12:28:15 -0600 Subject: [PATCH] Reduce target to ES2019, remove bigint literals (fixes #160) --- src/backends/store/inode.ts | 2 +- src/devices.ts | 4 ++-- src/stats.ts | 20 +++++++++++--------- tsconfig.json | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/backends/store/inode.ts b/src/backends/store/inode.ts index 51b4412a..0065ef84 100644 --- a/src/backends/store/inode.ts +++ b/src/backends/store/inode.ts @@ -6,7 +6,7 @@ import { randomBigInt } from '../../utils.js'; * Room inode * @hidden */ -export const rootIno = 0n; +export const rootIno = BigInt(0) as 0n; /** * Generic inode definition that can easily be serialized. diff --git a/src/devices.ts b/src/devices.ts index 4e33ff88..97cb166c 100644 --- a/src/devices.ts +++ b/src/devices.ts @@ -239,7 +239,7 @@ export class DeviceFS extends StoreFS { if (this.existsSync(path)) { throw ErrnoError.With('EEXIST', path, 'mknod'); } - let ino = 1n; + let ino = BigInt(1) as 1n; while (this.store.has(ino)) ino++; const dev = { driver, @@ -273,7 +273,7 @@ export class DeviceFS extends StoreFS { * @internal */ _createDevice(driver: DeviceDriver, options: object = {}): Device> { - let ino = 1n; + let ino = BigInt(1) as 1n; while (this.store.has(ino)) ino++; const dev = { driver, diff --git a/src/stats.ts b/src/stats.ts index 2340008d..481095ae 100644 --- a/src/stats.ts +++ b/src/stats.ts @@ -25,6 +25,8 @@ import { X_OK, } from './emulation/constants.js'; +const n1000 = BigInt(1000) as 1000n; + /** * Indicates the type of a file. Applied to 'mode'. */ @@ -305,19 +307,19 @@ export abstract class StatsCommon implements Node.Sta } public get atimeNs(): bigint { - return BigInt(this.atimeMs) * 1000n; + return BigInt(this.atimeMs) * n1000; } public get mtimeNs(): bigint { - return BigInt(this.mtimeMs) * 1000n; + return BigInt(this.mtimeMs) * n1000; } public get ctimeNs(): bigint { - return BigInt(this.ctimeMs) * 1000n; + return BigInt(this.ctimeMs) * n1000; } public get birthtimeNs(): bigint { - return BigInt(this.birthtimeMs) * 1000n; + return BigInt(this.birthtimeMs) * n1000; } } @@ -392,15 +394,15 @@ export class StatsFs implements Node.StatsFsBase { */ export class BigIntStatsFs implements Node.StatsFsBase { /** Type of file system. */ - public type: bigint = 0x7a656e6673n; + public type: bigint = BigInt('0x7a656e6673'); /** Optimal transfer block size. */ - public bsize: bigint = 4096n; + public bsize: bigint = BigInt(4096); /** Total data blocks in file system. */ - public blocks: bigint = 0n; + public blocks: bigint = BigInt(0); /** Free blocks in file system. */ - public bfree: bigint = 0n; + public bfree: bigint = BigInt(0); /** Available blocks for unprivileged users */ - public bavail: bigint = 0n; + public bavail: bigint = BigInt(0); /** Total file nodes in file system. */ public files: bigint = BigInt(size_max); /** Free file nodes in file system. */ diff --git a/tsconfig.json b/tsconfig.json index 5a9fe642..e21ef0e9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "NodeNext", - "target": "ES2020", + "target": "ES2019", "outDir": "dist", "lib": ["ESNext"], "moduleResolution": "NodeNext",