Skip to content

Class: MockLuaMap<K, V> ​

Mock tstl map data structure. In runtime objects, arrays and tables are same, but in test env have to mock them with compat and workarounds.

Extends ​

  • Map<K, V>

Type Parameters ​

Type ParameterDefault type
Kunknown
Vunknown

Constructors ​

Constructor ​

ts
new MockLuaMap<K, V>(entries?: readonly readonly [K, V][] | null): MockLuaMap<K, V>;

Parameters ​

ParameterType
entries?readonly readonly [K, V][] | null

Returns ​

MockLuaMap<K, V>

Inherited from ​

ts
Map<K, V>.constructor

Constructor ​

ts
new MockLuaMap<K, V>(iterable?: Iterable<readonly [K, V], any, any> | null): MockLuaMap<K, V>;

Parameters ​

ParameterType
iterable?Iterable<readonly [K, V], any, any> | null

Returns ​

MockLuaMap<K, V>

Inherited from ​

ts
Map<K, V>.constructor

Methods ​

getEntriesArray() ​

ts
getEntriesArray(): [K, V][];

Returns ​

[K, V][]


getKeysArray() ​

ts
getKeysArray(): K[];

Returns ​

K[]


getValuesArray() ​

ts
getValuesArray(): V[];

Returns ​

V[]


has() ​

ts
has(key: K): boolean;

Parameters ​

ParameterType
keyK

Returns ​

boolean

boolean indicating whether an element with the specified key exists or not.

Overrides ​

ts
Map.has

isEmpty() ​

ts
isEmpty(): boolean;

Check if table is empty.

Returns ​

boolean


length() ​

ts
length(): number;

Returns ​

number


map() ​

ts
map<U>(cb: (value: V, index: number, array: V[]) => U): U[];

Type Parameters ​

Type Parameter
U

Parameters ​

ParameterType
cb(value: V, index: number, array: V[]) => U

Returns ​

U[]


reset() ​

ts
reset(): void;

Returns ​

void


create() ​

ts
static create<K, V>(): MockLuaMap<K, V>;

Type Parameters ​

Type Parameter
K extends AnyNotNil
V

Returns ​

MockLuaMap<K, V>


fromArray() ​

ts
static fromArray<T>(from: T[], into?: MockLuaMap<number, T>): MockLuaMap<number, T>;

Create new map from JS array.

Type Parameters ​

Type Parameter
T

Parameters ​

ParameterType
fromT[]
intoMockLuaMap<number, T>

Returns ​

MockLuaMap<number, T>


fromObject() ​

ts
static fromObject<K, T>(from: Record<K, T>): MockLuaMap<K, T>;

Create new map from JS object.

Type Parameters ​

Type Parameter
K extends string | number | symbol
T

Parameters ​

ParameterType
fromRecord<K, T>

Returns ​

MockLuaMap<K, T>


getSizeOf() ​

ts
static getSizeOf(table: 
  | LuaTable<any, any>
  | LuaMap<any, any>
  | Map<any, any>
  | AnyObject): number;

Get mock size in unified way.

Parameters ​

ParameterType
table| LuaTable<any, any> | LuaMap<any, any> | Map<any, any> | AnyObject

Returns ​

number


mock() ​

ts
static mock<K, V>(initial?: [K, V][]): LuaTable<K, V>;

Type Parameters ​

Type Parameter
K extends AnyNotNil
V

Parameters ​

ParameterTypeDefault value
initial[K, V][][]

Returns ​

LuaTable<K, V>


mockFromObject() ​

ts
static mockFromObject<K, T>(from: Record<K, T>): MockLuaMap<K, T>;

Create new map from JS array.

Type Parameters ​

Type Parameter
K extends string | number | symbol
T

Parameters ​

ParameterType
fromRecord<K, T>

Returns ​

MockLuaMap<K, T>


mockToObject() ​

ts
static mockToObject<K, T>(from: MockLuaMap<K, T>): Record<K, T>;

Create new object from LUA table.

Type Parameters ​

Type Parameter
K extends string | number | symbol
T

Parameters ​

ParameterType
fromMockLuaMap<K, T>

Returns ​

Record<K, T>


toObject() ​

ts
static toObject<K, T>(from: MockLuaMap<K, T>): Record<K, T>;

Create new object from lua mock.

Type Parameters ​

Type Parameter
K extends string | number | symbol
T

Parameters ​

ParameterType
fromMockLuaMap<K, T>

Returns ​

Record<K, T>