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

Function arraySpeciesCreate

builtin_array.go:38–59  ·  view source on GitHub ↗
(obj *Object, size int64)

Source from the content-addressed store, hash-verified

36}
37
38func arraySpeciesCreate(obj *Object, size int64) *Object {
39 if isArray(obj) {
40 v := obj.self.getStr("constructor", nil)
41 if constructObj, ok := v.(*Object); ok {
42 v = constructObj.self.getSym(SymSpecies, nil)
43 if v == _null {
44 v = nil
45 }
46 }
47
48 if v != nil && v != _undefined {
49 constructObj, _ := v.(*Object)
50 if constructObj != nil {
51 if constructor := constructObj.self.assertConstructor(); constructor != nil {
52 return constructor([]Value{intToValue(size)}, constructObj)
53 }
54 }
55 panic(obj.runtime.NewTypeError("Species is not a constructor"))
56 }
57 }
58 return obj.runtime.newArrayLength(size)
59}
60
61func relToIdx(rel, l int64) int64 {
62 if rel >= 0 {

Callers 7

arrayproto_concatMethod · 0.85
arrayproto_sliceMethod · 0.85
arrayproto_spliceMethod · 0.85
arrayproto_mapMethod · 0.85
arrayproto_filterMethod · 0.85
arrayproto_flatMethod · 0.85
arrayproto_flatMapMethod · 0.85

Calls 7

isArrayFunction · 0.85
intToValueFunction · 0.85
NewTypeErrorMethod · 0.80
newArrayLengthMethod · 0.80
getStrMethod · 0.65
getSymMethod · 0.65
assertConstructorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…