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 Parameter | Default type |
|---|---|
K | unknown |
V | unknown |
Constructors
Constructor
ts
new MockLuaMap<K, V>(entries?: readonly readonly [K, V][] | null): MockLuaMap<K, V>;Parameters
| Parameter | Type |
|---|---|
entries? | readonly readonly [K, V][] | null |
Returns
MockLuaMap<K, V>
Inherited from
ts
Map<K, V>.constructorConstructor
ts
new MockLuaMap<K, V>(iterable?: Iterable<readonly [K, V], any, any> | null): MockLuaMap<K, V>;Parameters
| Parameter | Type |
|---|---|
iterable? | Iterable<readonly [K, V], any, any> | null |
Returns
MockLuaMap<K, V>
Inherited from
ts
Map<K, V>.constructorMethods
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
| Parameter | Type |
|---|---|
key | K |
Returns
boolean
boolean indicating whether an element with the specified key exists or not.
Overrides
ts
Map.hasisEmpty()
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
from | T[] |
into | MockLuaMap<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
| Parameter | Type |
|---|---|
from | Record<K, T> |
Returns
MockLuaMap<K, T>
getSizeOf()
ts
static getSizeOf(table: LuaTable<any, any> | AnyObject): number;Get mock size in unified way.
Parameters
| Parameter | Type |
|---|---|
table | LuaTable<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
| Parameter | Type | Default 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
| Parameter | Type |
|---|---|
from | Record<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
| Parameter | Type |
|---|---|
from | MockLuaMap<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
| Parameter | Type |
|---|---|
from | MockLuaMap<K, T> |
Returns
Record<K, T>