MCPcopy Create free account
hub / github.com/dop251/goja / createFunctionProtoTemplate

Function createFunctionProtoTemplate

builtin_function.go:230–254  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

228}
229
230func createFunctionProtoTemplate() *objectTemplate {
231 t := newObjectTemplate()
232 t.protoFactory = func(r *Runtime) *Object {
233 return r.global.ObjectPrototype
234 }
235
236 t.putStr("constructor", func(r *Runtime) Value { return valueProp(r.getFunction(), true, false, true) })
237
238 t.putStr("length", func(r *Runtime) Value { return valueProp(_positiveZero, false, false, true) })
239 t.putStr("name", func(r *Runtime) Value { return valueProp(stringEmpty, false, false, true) })
240
241 t.putStr("apply", func(r *Runtime) Value { return r.methodProp(r.functionproto_apply, "apply", 2) })
242 t.putStr("bind", func(r *Runtime) Value { return r.methodProp(r.functionproto_bind, "bind", 1) })
243 t.putStr("call", func(r *Runtime) Value { return r.methodProp(r.functionproto_call, "call", 1) })
244 t.putStr("toString", func(r *Runtime) Value { return r.methodProp(r.functionproto_toString, "toString", 0) })
245
246 t.putStr("caller", func(r *Runtime) Value { return r.newThrowerProperty(true) })
247 t.putStr("arguments", func(r *Runtime) Value { return r.newThrowerProperty(true) })
248
249 t.putSym(SymHasInstance, func(r *Runtime) Value {
250 return valueProp(r.newNativeFunc(r.functionproto_hasInstance, "[Symbol.hasInstance]", 1), false, false, false)
251 })
252
253 return t
254}
255
256var functionProtoTemplate *objectTemplate
257var functionProtoTemplateOnce sync.Once

Callers 1

getFunctionProtoTemplateFunction · 0.85

Calls 8

newObjectTemplateFunction · 0.85
valuePropFunction · 0.85
putStrMethod · 0.80
getFunctionMethod · 0.80
methodPropMethod · 0.80
newThrowerPropertyMethod · 0.80
putSymMethod · 0.80
newNativeFuncMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…