• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

project-slippi / slippi-js / 19973536637

05 Dec 2025 07:18PM UTC coverage: 81.336% (+0.08%) from 81.254%
19973536637

push

github

web-flow
Refactor SlippiGame to be web-compatible by default (#150)

* use EventTarget instead of event emitter

* fix event emitter shim

* stop using EventEmitter in stats

* it works!

* fix imports and typings

* create two distinct index.ts files for the different environments

* dont use accessor cuz it causes issues or something

* i think this actually works

* use cross env for windows env

* add node subpath to exports

* i think it actually works

* dts is not very configurable so use rollup directly instead

* don't hardcode filenames

* fix lint not working

* update readme to include distinction between web and node exports

* update example to use the node export

* fix windows builds

* separate common from other node exports

* i dont think slpReader should actually be exported

* for typesafety, don't accept string as input on the web

* remove unused dependency

* chore: fix eslint error

* minify for production

* chore(deps): remove unused lodash-es dependency

* chore(deps): remove tslib dependency

* reduce duplication

* reorganise structure

* try to fix windows build

* simplify build config

* add old style exports for backwards compatibility

* simplify browser constructor

* rename node/nodeUtils to just node/utils

* fix lint

* update error message with explicit node import path

* fix missing ws dependency issue with enet

* update package-lock.json

* update date-fns to match launcher version

* simplify buffer input ref creation

* make slpstream web-first

* fix issue with slp parsing expecting a frame

* create a single TextDecoder

* use .subarray() instead of .slice() where possible

* rename TypedEventTarget -> TypedEventEmitter

* try to fix build taking forever

* simplify TypedEventEmitter

* make node event emitters also type-safe

* add a once() method to event emitter

* deps: see if upgrading deps fixes random macos hangs

* working abstract class impl

* add missing getFilePath override

* bundle ubjson with requi... (continued)

694 of 928 branches covered (74.78%)

Branch coverage included in aggregate %.

158 of 178 new or added lines in 16 files covered. (88.76%)

1960 of 2335 relevant lines covered (83.94%)

119971.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
/src/node/utils/slpFileInputRef.ts
1
import fs from "fs";
12✔
2

3
import type { SlpInputRef } from "../../common/utils/slpInputRef";
4

5
export class SlpFileInputRef implements SlpInputRef {
12✔
6
  private fileDescriptor: number | null = null;
83✔
7

8
  public constructor(private readonly filePath: string) {}
83✔
9

10
  public open(): void {
11
    if (this.fileDescriptor) {
179✔
12
      // File is already open so do nothing
13
      return;
87✔
14
    }
15
    this.fileDescriptor = fs.openSync(this.filePath, "r");
92✔
16
  }
17

18
  public size(): number {
19
    if (!this.fileDescriptor) {
184!
NEW
20
      throw new Error("Tried to get the size of a closed SLP file");
×
21
    }
22
    return fs.fstatSync(this.fileDescriptor).size;
184✔
23
  }
24

25
  public close(): void {
26
    if (this.fileDescriptor) {
88✔
27
      fs.closeSync(this.fileDescriptor);
88✔
28
      this.fileDescriptor = null;
88✔
29
    }
30
  }
31

32
  public read(targetBuffer: Uint8Array, offset: number, length: number, position: number): number {
33
    if (!this.fileDescriptor) {
2,640,262!
NEW
34
      throw new Error("Tried to read from a closed SLP file");
×
35
    }
36

37
    return fs.readSync(this.fileDescriptor, targetBuffer, offset, length, position);
2,640,262✔
38
  }
39
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc