colyseus / schema

An incremental binary state serializer with delta encoding for games.
https://docs.colyseus.io/state/schema/
MIT License
134 stars 41 forks source link

fix ArraySchema#at with negative indexes #168

Closed sylvainpolletvillard closed 7 months ago

sylvainpolletvillard commented 7 months ago

This PR solves this problem:

Solution:

complete at method of ArraySchema based on TC39 polyfill (https://github.com/tc39/proposal-relative-indexing-method?tab=readme-ov-file#polyfill)

Once the library will target ES2022 code, we can simplify the code to Array.from(this.$items.keys()).at(index)

endel commented 7 months ago

That's neat, thank you @sylvainpolletvillard 🎉