Skip to content

Commit

Permalink
feat: update typescript version and satisfy BinaryIO's underlying Dat…
Browse files Browse the repository at this point in the history
…aView's generic
  • Loading branch information
meszaros-lajos-gyorgy committed Dec 24, 2024
1 parent eaf08c0 commit 033f5da
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 24 deletions.
21 changes: 4 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"eslint-plugin-unused-imports": "^4.1.4",
"nodemon": "^3.1.9",
"tsc-alias": "^1.8.10",
"typescript": "5.6.3",
"typescript": "5.7.2",
"xo": "^0.60.0"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion src/bin/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function fileExists(filename: string): Promise<boolean> {

export async function streamToBuffer(input: NodeJS.ReadableStream): Promise<ArrayBuffer> {
return new Promise((resolve, reject) => {
const chunks: ArrayBuffer[] = []
const chunks: ArrayBufferLike[] = []

input.on('data', (chunk: Buffer) => {
chunks.push(chunk.buffer)
Expand Down
2 changes: 1 addition & 1 deletion src/common/BinaryIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { decodeText, encodeText, repeat } from '@common/helpers.js'
import { LITTLE_ENDIAN, TRUNCATE_ZERO_BYTES, KEEP_ZERO_BYTES, BYTE_OF_AN_UNKNOWN_CHAR } from '@common/constants.js'
import { type ArxQuaternion, type ArxRotation, type ArxVector3 } from '@common/types.js'

export class BinaryIO extends DataView {
export class BinaryIO extends DataView<ArrayBuffer> {
static sizeOfFloat32(): 4 {
return 4 as const
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function clamp(min: number, max: number, n: number): number {
/**
* @see https://stackoverflow.com/a/49129872/1806628
*/
export function concatArrayBuffers(buffers: ArrayBuffer[]): ArrayBuffer {
export function concatArrayBuffers(buffers: ArrayBufferLike[]): ArrayBuffer {
if (buffers.length === 0) {
return new ArrayBuffer(0)
}
Expand Down
4 changes: 2 additions & 2 deletions src/dlf/ZoneAndPathHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ export class ZoneAndPathHeader {
}
}

static allocateFrom(zoneOrPath: ArxZone | ArxPath): Uint8Array {
const buffer = new Uint8Array(ZoneAndPathHeader.sizeOf())
static allocateFrom(zoneOrPath: ArxZone | ArxPath): ArrayBuffer {
const buffer = new ArrayBuffer(ZoneAndPathHeader.sizeOf())
const binary = new BinaryIO(buffer)

const { pos } = zoneOrPath.points[0]
Expand Down
2 changes: 1 addition & 1 deletion src/ftl/FTL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class FTL {
const groups = concatArrayBuffers(json.groups.map(Group.accumulateFrom))
const indices = concatArrayBuffers(
json.groups.map(({ indices }) => {
const buffer = new Uint8Array(BinaryIO.sizeOfInt32Array(indices.length))
const buffer = new ArrayBuffer(BinaryIO.sizeOfInt32Array(indices.length))
const binary = new BinaryIO(buffer)
binary.writeInt32Array(indices)
return buffer
Expand Down

0 comments on commit 033f5da

Please sign in to comment.