File tree Expand file tree Collapse file tree 2 files changed +3
-4
lines changed Expand file tree Collapse file tree 2 files changed +3
-4
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @colyseus/schema" ,
3
- "version" : " 3.0.0 " ,
3
+ "version" : " 3.0.1 " ,
4
4
"description" : " Binary state serializer with delta encoding for games" ,
5
5
"bin" : {
6
6
"schema-codegen" : " ./bin/schema-codegen" ,
Original file line number Diff line number Diff line change @@ -7,13 +7,12 @@ import type { Iterator } from "../encoding/decode";
7
7
8
8
import { OPERATION , SWITCH_TO_STRUCTURE , TYPE_ID } from '../encoding/spec' ;
9
9
import { Root } from "./Root" ;
10
- import { getNextPowerOf2 } from "../utils" ;
11
10
12
11
import type { StateView } from "./StateView" ;
13
12
import type { Metadata } from "../Metadata" ;
14
13
15
14
export class Encoder < T extends Schema = any > {
16
- static BUFFER_SIZE = Buffer . poolSize ?? 8 * 1024 ; // 8KB
15
+ static BUFFER_SIZE = ( typeof ( Buffer ) !== "undefined" ) && Buffer . poolSize || 8 * 1024 ; // 8KB
17
16
sharedBuffer = Buffer . allocUnsafe ( Encoder . BUFFER_SIZE ) ;
18
17
19
18
context : TypeContext ;
@@ -119,7 +118,7 @@ export class Encoder<T extends Schema = any> {
119
118
// we can assume that n + 1 poolSize will suffice given that we are likely done with encoding at this point
120
119
// multiples of poolSize are faster to allocate than arbitrary sizes
121
120
// if we are on an older platform that doesn't implement pooling use 8kb as poolSize (that's the default for node)
122
- const newSize = Math . ceil ( it . offset / ( Buffer . poolSize ?? 8 * 1024 ) ) * ( Buffer . poolSize ?? 8 * 1024 ) ;
121
+ const newSize = Math . ceil ( it . offset / ( Buffer . poolSize ?? 8 * 1024 ) ) * ( Buffer . poolSize ?? 8 * 1024 ) ;
123
122
124
123
console . warn ( `@colyseus/schema buffer overflow. Encoded state is higher than default BUFFER_SIZE. Use the following to increase default BUFFER_SIZE:
125
124
You can’t perform that action at this time.
0 commit comments