New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@colyseus/schema

Package Overview
Dependencies
Maintainers
0
Versions
337
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.1 to 3.0.2

28

lib/types/custom/MapSchema.d.ts

@@ -5,6 +5,6 @@ import { $changes, $decoder, $deleteByIndex, $onEncodeEnd, $encoder, $filter, $getByIndex } from "../symbols";

import type { StateView } from "../../encoder/StateView";
export declare class MapSchema<V = any> implements Map<string, V>, Collection<string, V, [string, V]> {
export declare class MapSchema<V = any, K extends string = string> implements Map<K, V>, Collection<K, V, [K, V]> {
protected childType: new () => V;
protected $items: Map<string, V>;
protected $indexes: Map<number, string>;
protected $items: Map<K, V>;
protected $indexes: Map<number, K>;
protected [$changes]: ChangeTree;

@@ -24,19 +24,19 @@ static [$encoder]: import("../../encoder/EncodeOperation").EncodeOperation<any>;

static is(type: any): boolean;
constructor(initialValues?: Map<string, V> | Record<string, V>);
constructor(initialValues?: Map<K, V> | Record<K, V>);
/** Iterator */
[Symbol.iterator](): IterableIterator<[string, V]>;
[Symbol.iterator](): IterableIterator<[K, V]>;
get [Symbol.toStringTag](): string;
static get [Symbol.species](): typeof MapSchema;
set(key: string, value: V): this;
get(key: string): V | undefined;
delete(key: string): boolean;
set(key: K, value: V): this;
get(key: K): V | undefined;
delete(key: K): boolean;
clear(): void;
has(key: string): boolean;
forEach(callbackfn: (value: V, key: string, map: Map<string, V>) => void): void;
entries(): MapIterator<[string, V]>;
keys(): MapIterator<string>;
has(key: K): boolean;
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void): void;
entries(): MapIterator<[K, V]>;
keys(): MapIterator<K>;
values(): MapIterator<V>;
get size(): number;
protected setIndex(index: number, key: string): void;
protected getIndex(index: number): string;
protected setIndex(index: number, key: K): void;
protected getIndex(index: number): K;
protected [$getByIndex](index: number): V;

@@ -43,0 +43,0 @@ protected [$deleteByIndex](index: number): void;

{
"name": "@colyseus/schema",
"version": "3.0.1",
"version": "3.0.2",
"description": "Binary state serializer with delta encoding for games",

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

@@ -12,7 +12,7 @@ import { $changes, $childType, $decoder, $deleteByIndex, $onEncodeEnd, $encoder, $filter, $getByIndex, $numFields } from "../symbols";

export class MapSchema<V=any> implements Map<string, V>, Collection<string, V, [string, V]> {
export class MapSchema<V=any, K extends string = string> implements Map<K, V>, Collection<K, V, [K, V]> {
protected childType: new () => V;
protected $items: Map<string, V> = new Map<string, V>();
protected $indexes: Map<number, string> = new Map<number, string>();
protected $items: Map<K, V> = new Map<K, V>();
protected $indexes: Map<number, K> = new Map<number, K>();

@@ -45,3 +45,3 @@ protected [$changes]: ChangeTree;

constructor (initialValues?: Map<string, V> | Record<string, V>) {
constructor (initialValues?: Map<K, V> | Record<K, V>) {
this[$changes] = new ChangeTree(this);

@@ -73,3 +73,3 @@ this[$changes].indexes = {};

/** Iterator */
[Symbol.iterator](): IterableIterator<[string, V]> { return this.$items[Symbol.iterator](); }
[Symbol.iterator](): IterableIterator<[K, V]> { return this.$items[Symbol.iterator](); }
get [Symbol.toStringTag]() { return this.$items[Symbol.toStringTag] }

@@ -79,3 +79,3 @@

set(key: string, value: V) {
set(key: K, value: V) {
if (value === undefined || value === null) {

@@ -90,3 +90,3 @@ throw new Error(`MapSchema#set('${key}', ${value}): trying to set ${value} value on '${key}'.`);

// See: https://github.com/colyseus/colyseus/issues/561#issuecomment-1646733468
key = key.toString() as string;
key = key.toString() as K;

@@ -146,7 +146,7 @@ const changeTree = this[$changes];

get(key: string): V | undefined {
get(key: K): V | undefined {
return this.$items.get(key);
}
delete(key: string) {
delete(key: K) {
const index = this[$changes].indexes[key];

@@ -175,7 +175,7 @@

has (key: string) {
has (key: K) {
return this.$items.has(key);
}
forEach(callbackfn: (value: V, key: string, map: Map<string, V>) => void) {
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void) {
this.$items.forEach(callbackfn);

@@ -200,3 +200,3 @@ }

protected setIndex(index: number, key: string) {
protected setIndex(index: number, key: K) {
this.$indexes.set(index, key);

@@ -203,0 +203,0 @@ }

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

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