Skip to content

Commit

Permalink
Allow SlippiGame to accept an ArrayBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
frankborden committed Jun 23, 2021
1 parent 1c2fe87 commit c9d936a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/SlippiGame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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");
}
Expand Down

0 comments on commit c9d936a

Please sign in to comment.