Skip to content

Commit

Permalink
Reduce target to ES2019, remove bigint literals (fixes #160)
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Dec 19, 2024
1 parent 3887a8a commit 0bc5e7e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/backends/store/inode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/devices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class DeviceFS extends StoreFS<InMemoryStore> {
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,
Expand Down Expand Up @@ -273,7 +273,7 @@ export class DeviceFS extends StoreFS<InMemoryStore> {
* @internal
*/
_createDevice<TData = any>(driver: DeviceDriver<TData>, options: object = {}): Device<TData | Record<string, never>> {

Check warning on line 275 in src/devices.ts

View workflow job for this annotation

GitHub Actions / CI

Unexpected any. Specify a different type
let ino = 1n;
let ino = BigInt(1) as 1n;
while (this.store.has(ino)) ino++;
const dev = {
driver,
Expand Down
20 changes: 11 additions & 9 deletions src/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
*/
Expand Down Expand Up @@ -305,19 +307,19 @@ export abstract class StatsCommon<T extends number | bigint> 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;
}
}

Expand Down Expand Up @@ -392,15 +394,15 @@ export class StatsFs implements Node.StatsFsBase<number> {
*/
export class BigIntStatsFs implements Node.StatsFsBase<bigint> {
/** 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. */
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"module": "NodeNext",
"target": "ES2020",
"target": "ES2019",
"outDir": "dist",
"lib": ["ESNext"],
"moduleResolution": "NodeNext",
Expand Down

0 comments on commit 0bc5e7e

Please sign in to comment.