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

Method pushValue

src/type-extensions/proxy.ts:138–169  ·  view source on GitHub ↗
(thread: Thread, decoratedValue: Decoration<any, ProxyDecorationOptions>)

Source from the content-addressed store, hash-verified

136 }
137
138 public pushValue(thread: Thread, decoratedValue: Decoration<any, ProxyDecorationOptions>): boolean {
139 const { target, options } = decoratedValue
140 if (options.proxy === undefined) {
141 if (target === null || target === undefined) {
142 return false
143 }
144
145 if (typeof target !== 'object') {
146 const isClass =
147 typeof target === 'function' && target.prototype?.constructor === target && target.toString().startsWith('class ')
148
149 if (!isClass) {
150 return false
151 }
152 }
153
154 if (isPromise(target)) {
155 return false
156 }
157 } else if (options.proxy === false) {
158 return false
159 }
160
161 if (options.metatable && !(options.metatable instanceof Decoration)) {
162 // Otherwise the metatable will get converted into a JS ref rather than being set as a standard
163 // table. This forces it to use the standard table type.
164 decoratedValue.options.metatable = decorateProxy(options.metatable, { proxy: false })
165 return false
166 }
167
168 return super.pushValue(thread, decoratedValue)
169 }
170
171 public close(): void {
172 this.thread.lua.module.removeFunction(this.gcPointer)

Callers 1

constructorMethod · 0.45

Calls 2

isPromiseFunction · 0.90
decorateProxyFunction · 0.85

Tested by

no test coverage detected