@colyseus/schema
Advanced tools
Comparing version 3.0.0-alpha.0 to 3.0.0-alpha.1
@@ -24,17 +24,19 @@ /** | ||
/// <reference types="node" /> | ||
import type { Iterator } from "./decode"; | ||
export type BufferLike = number[] | ArrayBufferLike; | ||
export declare function utf8Write(view: any, str: any, it: any): void; | ||
export declare function int8(bytes: any, value: any, it: any): void; | ||
export declare function uint8(bytes: any, value: any, it: any): void; | ||
export declare function int16(bytes: any, value: any, it: any): void; | ||
export declare function uint16(bytes: any, value: any, it: any): void; | ||
export declare function int32(bytes: any, value: any, it: any): void; | ||
export declare function uint32(bytes: any, value: any, it: any): void; | ||
export declare function int64(bytes: any, value: any, it: any): void; | ||
export declare function uint64(bytes: any, value: any, it: any): void; | ||
export declare function float32(bytes: any, value: any, it: any): void; | ||
export declare function float64(bytes: any, value: any, it: any): void; | ||
export declare function writeFloat32(bytes: any, value: any, it: any): void; | ||
export declare function writeFloat64(bytes: any, value: any, it: any): void; | ||
export declare function boolean(bytes: any, value: any, it: any): void; | ||
export declare function string(bytes: Buffer, value: any, it: any): number; | ||
export declare function number(bytes: any, value: any, it: any): 1 | 2 | 3 | 5 | 9; | ||
export declare function int8(bytes: BufferLike, value: number, it: Iterator): void; | ||
export declare function uint8(bytes: BufferLike, value: number, it: Iterator): void; | ||
export declare function int16(bytes: BufferLike, value: number, it: Iterator): void; | ||
export declare function uint16(bytes: BufferLike, value: number, it: Iterator): void; | ||
export declare function int32(bytes: BufferLike, value: number, it: Iterator): void; | ||
export declare function uint32(bytes: BufferLike, value: number, it: Iterator): void; | ||
export declare function int64(bytes: BufferLike, value: number, it: Iterator): void; | ||
export declare function uint64(bytes: BufferLike, value: number, it: Iterator): void; | ||
export declare function float32(bytes: BufferLike, value: number, it: Iterator): void; | ||
export declare function float64(bytes: BufferLike, value: number, it: Iterator): void; | ||
export declare function writeFloat32(bytes: BufferLike, value: number, it: Iterator): void; | ||
export declare function writeFloat64(bytes: BufferLike, value: number, it: Iterator): void; | ||
export declare function boolean(bytes: BufferLike, value: number, it: Iterator): void; | ||
export declare function string(bytes: Buffer, value: string, it: Iterator): number; | ||
export declare function number(bytes: BufferLike, value: number, it: Iterator): 1 | 2 | 3 | 5 | 9; |
{ | ||
"name": "@colyseus/schema", | ||
"version": "3.0.0-alpha.0", | ||
"version": "3.0.0-alpha.1", | ||
"description": "Binary state serializer with delta encoding for games", | ||
@@ -5,0 +5,0 @@ "bin": { |
@@ -25,3 +25,6 @@ /** | ||
import type { TextEncoder } from "util"; | ||
import type { Iterator } from "./decode"; | ||
export type BufferLike = number[] | ArrayBufferLike; | ||
/** | ||
@@ -84,11 +87,11 @@ * msgpack implementation highly based on notepack.io | ||
export function int8(bytes, value, it) { | ||
export function int8(bytes: BufferLike, value: number, it: Iterator) { | ||
bytes[it.offset++] = value & 255; | ||
}; | ||
export function uint8(bytes, value, it) { | ||
export function uint8(bytes: BufferLike, value: number, it: Iterator) { | ||
bytes[it.offset++] = value & 255; | ||
}; | ||
export function int16(bytes, value, it) { | ||
export function int16(bytes: BufferLike, value: number, it: Iterator) { | ||
bytes[it.offset++] = value & 255; | ||
@@ -98,3 +101,3 @@ bytes[it.offset++] = (value >> 8) & 255; | ||
export function uint16(bytes, value, it) { | ||
export function uint16(bytes: BufferLike, value: number, it: Iterator) { | ||
bytes[it.offset++] = value & 255; | ||
@@ -104,3 +107,3 @@ bytes[it.offset++] = (value >> 8) & 255; | ||
export function int32(bytes, value, it) { | ||
export function int32(bytes: BufferLike, value: number, it: Iterator) { | ||
bytes[it.offset++] = value & 255; | ||
@@ -112,3 +115,3 @@ bytes[it.offset++] = (value >> 8) & 255; | ||
export function uint32(bytes, value, it) { | ||
export function uint32(bytes: BufferLike, value: number, it: Iterator) { | ||
const b4 = value >> 24; | ||
@@ -124,3 +127,3 @@ const b3 = value >> 16; | ||
export function int64(bytes, value, it) { | ||
export function int64(bytes: BufferLike, value: number, it: Iterator) { | ||
const high = Math.floor(value / Math.pow(2, 32)); | ||
@@ -132,3 +135,3 @@ const low = value >>> 0; | ||
export function uint64(bytes, value, it) { | ||
export function uint64(bytes: BufferLike, value: number, it: Iterator) { | ||
const high = (value / Math.pow(2, 32)) >> 0; | ||
@@ -140,7 +143,7 @@ const low = value >>> 0; | ||
export function float32(bytes, value, it) { | ||
export function float32(bytes: BufferLike, value: number, it: Iterator) { | ||
writeFloat32(bytes, value, it); | ||
} | ||
export function float64(bytes, value, it) { | ||
export function float64(bytes: BufferLike, value: number, it: Iterator) { | ||
writeFloat64(bytes, value, it); | ||
@@ -155,3 +158,3 @@ } | ||
export function writeFloat32(bytes, value, it) { | ||
export function writeFloat32(bytes: BufferLike, value: number, it: Iterator) { | ||
_float32[0] = value; | ||
@@ -161,3 +164,3 @@ int32(bytes, _int32[0], it); | ||
export function writeFloat64(bytes, value, it) { | ||
export function writeFloat64(bytes: BufferLike, value: number, it: Iterator) { | ||
_float64[0] = value; | ||
@@ -168,7 +171,7 @@ int32(bytes, _int32[_isLittleEndian ? 0 : 1], it); | ||
export function boolean(bytes, value, it) { | ||
export function boolean(bytes: BufferLike, value: number, it: Iterator) { | ||
bytes[it.offset++] = value ? 1 : 0; // uint8 | ||
}; | ||
export function string(bytes: Buffer, value, it) { | ||
export function string(bytes: Buffer, value: string, it: Iterator) { | ||
// encode `null` strings as empty. | ||
@@ -212,3 +215,3 @@ if (!value) { value = ""; } | ||
export function number(bytes, value, it) { | ||
export function number(bytes: BufferLike, value: number, it: Iterator) { | ||
if (isNaN(value)) { | ||
@@ -215,0 +218,0 @@ return number(bytes, 0, it); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
2459995
29916