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

Method arrayproto_flat

builtin_array.go:1193–1203  ·  view source on GitHub ↗
(call FunctionCall)

Source from the content-addressed store, hash-verified

1191}
1192
1193func (r *Runtime) arrayproto_flat(call FunctionCall) Value {
1194 o := call.This.ToObject(r)
1195 l := toLength(o.self.getStr("length", nil))
1196 depthNum := int64(1)
1197 if len(call.Arguments) > 0 {
1198 depthNum = call.Argument(0).ToInteger()
1199 }
1200 a := arraySpeciesCreate(o, 0)
1201 r.flattenIntoArray(a, o, l, 0, depthNum, nil, nil)
1202 return a
1203}
1204
1205func (r *Runtime) flattenIntoArray(target, source *Object, sourceLen, start, depth int64, mapperFunction func(FunctionCall) Value, thisArg Value) int64 {
1206 targetIndex, sourceIndex := start, int64(0)

Callers

nothing calls this directly

Calls 7

flattenIntoArrayMethod · 0.95
toLengthFunction · 0.85
arraySpeciesCreateFunction · 0.85
ToObjectMethod · 0.65
getStrMethod · 0.65
ToIntegerMethod · 0.65
ArgumentMethod · 0.45

Tested by

no test coverage detected