Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@colyseus/schema

Package Overview
Dependencies
Maintainers
1
Versions
313
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@colyseus/schema - npm Package Compare versions

Comparing version 3.0.0-alpha.2 to 3.0.0-alpha.3

40

lib/encoding/decode.d.ts

@@ -23,2 +23,3 @@ /**

*/
import type { BufferLike } from "./encode";
/**

@@ -31,20 +32,21 @@ * msgpack implementation highly based on notepack.io

}
export declare function int8(bytes: number[], it: Iterator): number;
export declare function uint8(bytes: number[], it: Iterator): number;
export declare function int16(bytes: number[], it: Iterator): number;
export declare function uint16(bytes: number[], it: Iterator): number;
export declare function int32(bytes: number[], it: Iterator): number;
export declare function uint32(bytes: number[], it: Iterator): number;
export declare function float32(bytes: number[], it: Iterator): number;
export declare function float64(bytes: number[], it: Iterator): number;
export declare function int64(bytes: number[], it: Iterator): number;
export declare function uint64(bytes: number[], it: Iterator): number;
export declare function readFloat32(bytes: number[], it: Iterator): number;
export declare function readFloat64(bytes: number[], it: Iterator): number;
export declare function boolean(bytes: number[], it: Iterator): boolean;
export declare function string(bytes: any, it: Iterator): string;
export declare function stringCheck(bytes: any, it: Iterator): boolean;
export declare function number(bytes: any, it: Iterator): any;
export declare function numberCheck(bytes: any, it: Iterator): boolean;
export declare function arrayCheck(bytes: any, it: Iterator): boolean;
export declare function switchStructureCheck(bytes: any, it: Iterator): boolean;
export declare function utf8Read(bytes: BufferLike, it: Iterator, length: number): string;
export declare function int8(bytes: BufferLike, it: Iterator): number;
export declare function uint8(bytes: BufferLike, it: Iterator): any;
export declare function int16(bytes: BufferLike, it: Iterator): number;
export declare function uint16(bytes: BufferLike, it: Iterator): number;
export declare function int32(bytes: BufferLike, it: Iterator): number;
export declare function uint32(bytes: BufferLike, it: Iterator): number;
export declare function float32(bytes: BufferLike, it: Iterator): number;
export declare function float64(bytes: BufferLike, it: Iterator): number;
export declare function int64(bytes: BufferLike, it: Iterator): number;
export declare function uint64(bytes: BufferLike, it: Iterator): number;
export declare function readFloat32(bytes: BufferLike, it: Iterator): number;
export declare function readFloat64(bytes: BufferLike, it: Iterator): number;
export declare function boolean(bytes: BufferLike, it: Iterator): boolean;
export declare function string(bytes: BufferLike, it: Iterator): string;
export declare function stringCheck(bytes: BufferLike, it: Iterator): boolean;
export declare function number(bytes: BufferLike, it: Iterator): any;
export declare function numberCheck(bytes: BufferLike, it: Iterator): boolean;
export declare function arrayCheck(bytes: BufferLike, it: Iterator): boolean;
export declare function switchStructureCheck(bytes: BufferLike, it: Iterator): boolean;

@@ -25,7 +25,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.switchStructureCheck = exports.arrayCheck = exports.numberCheck = exports.number = exports.stringCheck = exports.string = exports.boolean = exports.readFloat64 = exports.readFloat32 = exports.uint64 = exports.int64 = exports.float64 = exports.float32 = exports.uint32 = exports.int32 = exports.uint16 = exports.int16 = exports.uint8 = exports.int8 = void 0;
exports.switchStructureCheck = exports.arrayCheck = exports.numberCheck = exports.number = exports.stringCheck = exports.string = exports.boolean = exports.readFloat64 = exports.readFloat32 = exports.uint64 = exports.int64 = exports.float64 = exports.float32 = exports.uint32 = exports.int32 = exports.uint16 = exports.int16 = exports.uint8 = exports.int8 = exports.utf8Read = void 0;
const spec_1 = require("./spec");
function utf8Read(bytes, offset, length) {
function utf8Read(bytes, it, length) {
it.offset += length;
var string = '', chr = 0;
for (var i = offset, end = offset + length; i < end; i++) {
for (var i = it.offset, end = it.offset + length; i < end; i++) {
var byte = bytes[i];

@@ -67,2 +68,3 @@ if ((byte & 0x80) === 0x00) {

}
exports.utf8Read = utf8Read;
function int8(bytes, it) {

@@ -159,5 +161,3 @@ return uint8(bytes, it) << 24 >> 24;

}
const value = utf8Read(bytes, it.offset, length);
it.offset += length;
return value;
return utf8Read(bytes, it, length);
}

@@ -164,0 +164,0 @@ exports.string = string;

{
"name": "@colyseus/schema",
"version": "3.0.0-alpha.2",
"version": "3.0.0-alpha.3",
"description": "Binary state serializer with delta encoding for games",

@@ -5,0 +5,0 @@ "bin": {

@@ -25,2 +25,3 @@ /**

import { SWITCH_TO_STRUCTURE } from "./spec";
import type { BufferLike } from "./encode";

@@ -34,5 +35,7 @@ /**

function utf8Read(bytes, offset, length) {
export function utf8Read(bytes: BufferLike, it: Iterator, length: number) {
it.offset += length;
var string = '', chr = 0;
for (var i = offset, end = offset + length; i < end; i++) {
for (var i = it.offset, end = it.offset + length; i < end; i++) {
var byte = bytes[i];

@@ -79,35 +82,35 @@ if ((byte & 0x80) === 0x00) {

export function int8 (bytes: number[], it: Iterator) {
export function int8 (bytes: BufferLike, it: Iterator) {
return uint8(bytes, it) << 24 >> 24;
};
export function uint8 (bytes: number[], it: Iterator) {
export function uint8 (bytes: BufferLike, it: Iterator) {
return bytes[it.offset++];
};
export function int16 (bytes: number[], it: Iterator) {
export function int16 (bytes: BufferLike, it: Iterator) {
return uint16(bytes, it) << 16 >> 16;
};
export function uint16 (bytes: number[], it: Iterator) {
export function uint16 (bytes: BufferLike, it: Iterator) {
return bytes[it.offset++] | bytes[it.offset++] << 8;
};
export function int32 (bytes: number[], it: Iterator) {
export function int32 (bytes: BufferLike, it: Iterator) {
return bytes[it.offset++] | bytes[it.offset++] << 8 | bytes[it.offset++] << 16 | bytes[it.offset++] << 24;
};
export function uint32 (bytes: number[], it: Iterator) {
export function uint32 (bytes: BufferLike, it: Iterator) {
return int32(bytes, it) >>> 0;
};
export function float32(bytes: number[], it: Iterator) {
export function float32(bytes: BufferLike, it: Iterator) {
return readFloat32(bytes, it);
}
export function float64(bytes: number[], it: Iterator) {
export function float64(bytes: BufferLike, it: Iterator) {
return readFloat64(bytes, it);
}
export function int64(bytes: number[], it: Iterator) {
export function int64(bytes: BufferLike, it: Iterator) {
const low = uint32(bytes, it);

@@ -118,3 +121,3 @@ const high = int32(bytes, it) * Math.pow(2, 32);

export function uint64(bytes: number[], it: Iterator) {
export function uint64(bytes: BufferLike, it: Iterator) {
const low = uint32(bytes, it);

@@ -131,3 +134,3 @@ const high = uint32(bytes, it) * Math.pow(2, 32);

export function readFloat32 (bytes: number[], it: Iterator) {
export function readFloat32 (bytes: BufferLike, it: Iterator) {
_int32[0] = int32(bytes, it);

@@ -137,3 +140,3 @@ return _float32[0];

export function readFloat64 (bytes: number[], it: Iterator) {
export function readFloat64 (bytes: BufferLike, it: Iterator) {
_int32[_isLittleEndian ? 0 : 1] = int32(bytes, it);

@@ -144,7 +147,7 @@ _int32[_isLittleEndian ? 1 : 0] = int32(bytes, it);

export function boolean (bytes: number[], it: Iterator) {
export function boolean (bytes: BufferLike, it: Iterator) {
return uint8(bytes, it) > 0;
};
export function string (bytes, it: Iterator) {
export function string (bytes: BufferLike, it: Iterator) {
const prefix = bytes[it.offset++];

@@ -167,9 +170,6 @@ let length: number;

const value = utf8Read(bytes, it.offset, length);
it.offset += length;
return value;
return utf8Read(bytes, it, length);
}
export function stringCheck(bytes, it: Iterator) {
export function stringCheck(bytes: BufferLike, it: Iterator) {
const prefix = bytes[it.offset];

@@ -188,3 +188,3 @@ return (

export function number (bytes, it: Iterator) {
export function number (bytes: BufferLike, it: Iterator) {
const prefix = bytes[it.offset++];

@@ -242,3 +242,3 @@

export function numberCheck (bytes, it: Iterator) {
export function numberCheck (bytes: BufferLike, it: Iterator) {
const prefix = bytes[it.offset];

@@ -262,3 +262,3 @@ // positive fixint - 0x00 - 0x7f

export function arrayCheck (bytes, it: Iterator) {
export function arrayCheck (bytes: BufferLike, it: Iterator) {
return bytes[it.offset] < 0xa0;

@@ -282,3 +282,3 @@

export function switchStructureCheck(bytes, it: Iterator) {
export function switchStructureCheck(bytes: BufferLike, it: Iterator) {
return (

@@ -285,0 +285,0 @@ // previous byte should be `SWITCH_TO_STRUCTURE`

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 not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc