Skip to content

Commit 36c6aeb

Browse files
committed
fix ArraySchema#filter() return type. fixes #172
1 parent ce9bdd5 commit 36c6aeb

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@colyseus/schema",
3-
"version": "2.0.31",
3+
"version": "2.0.32",
44
"description": "Binary state serializer with delta encoding for games",
55
"bin": {
66
"schema-codegen": "./bin/schema-codegen"

src/types/ArraySchema.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,13 @@ export class ArraySchema<V = any> implements Array<V>, SchemaDecoderCallbacks {
167167
//
168168
// FIXME: this should be O(1)
169169
//
170-
170+
171171
index = Math.trunc(index) || 0;
172172
// Allow negative indexing from the end
173173
if (index < 0) index += this.length;
174174
// OOB access is guaranteed to return undefined
175175
if (index < 0 || index >= this.length) return undefined;
176-
176+
177177
const key = Array.from(this.$items.keys())[index];
178178
return this.$items.get(key);
179179
}
@@ -434,7 +434,7 @@ export class ArraySchema<V = any> implements Array<V>, SchemaDecoderCallbacks {
434434
* @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.
435435
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
436436
*/
437-
filter(callbackfn: (value: V, index: number, array: V[]) => unknown, thisArg?: any)
437+
filter(callbackfn: (value: V, index: number, array: V[]) => unknown, thisArg?: any): V[]
438438
filter<S extends V>(callbackfn: (value: V, index: number, array: V[]) => value is S, thisArg?: any): V[] {
439439
return Array.from(this.$items.values()).filter(callbackfn, thisArg);
440440
}

0 commit comments

Comments
 (0)