From c9d936abaddeaa798558b95b6fda3213a1285004 Mon Sep 17 00:00:00 2001 From: Frank Borden Date: Wed, 23 Jun 2021 22:21:24 +0000 Subject: [PATCH] Allow SlippiGame to accept an ArrayBuffer --- src/SlippiGame.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SlippiGame.ts b/src/SlippiGame.ts index 83e8791e..c08a75fd 100644 --- a/src/SlippiGame.ts +++ b/src/SlippiGame.ts @@ -32,7 +32,7 @@ export class SlippiGame { private inputComputer: InputComputer = new InputComputer(); private statsComputer: Stats; - public constructor(input: string | Buffer, opts?: StatOptions) { + public constructor(input: string | Buffer | ArrayBuffer, opts?: StatOptions) { if (_.isString(input)) { this.input = { source: SlpInputSource.FILE, @@ -43,6 +43,11 @@ export class SlippiGame { source: SlpInputSource.BUFFER, buffer: input, }; + } else if (input instanceof ArrayBuffer) { + this.input = { + source: SlpInputSource.BUFFER, + buffer: Buffer.from(input), + }; } else { throw new Error("Cannot create SlippiGame with input of that type"); }