MCPcopy Create free account
hub / github.com/ceifa/wasmoon / getValue

Method getValue

src/type-extensions/table.ts:22–39  ·  view source on GitHub ↗
(thread: Thread, index: number, userdata?: any)

Source from the content-addressed store, hash-verified

20 }
21
22 public getValue(thread: Thread, index: number, userdata?: any): TableType {
23 // This is a map of Lua pointers to JS objects.
24 const seenMap: Map<number, TableType> = userdata || new Map()
25 const pointer = thread.lua.lua_topointer(thread.address, index)
26
27 let table = seenMap.get(pointer)
28 if (!table) {
29 const keys = this.readTableKeys(thread, index)
30
31 const isSequential = keys.length > 0 && keys.every((key, index) => key === String(index + 1))
32 table = isSequential ? [] : {}
33
34 seenMap.set(pointer, table)
35 this.readTableValues(thread, index, seenMap, table)
36 }
37
38 return table
39 }
40
41 public pushValue(thread: Thread, { target }: Decoration<TableType>, userdata?: Map<any, number>): boolean {
42 if (typeof target !== 'object' || target === null) {

Callers 1

readTableValuesMethod · 0.45

Calls 4

readTableKeysMethod · 0.95
readTableValuesMethod · 0.95
getMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected