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

Method export

array_sparse.go:432–465  ·  view source on GitHub ↗
(ctx *objectExportCtx)

Source from the content-addressed store, hash-verified

430}
431
432func (a *sparseArrayObject) export(ctx *objectExportCtx) interface{} {
433 if v, exists := ctx.get(a.val); exists {
434 return v
435 }
436 arr := make([]interface{}, a.length)
437 ctx.put(a.val, arr)
438 var prevIdx uint32
439 for _, item := range a.items {
440 idx := item.idx
441 for i := prevIdx; i < idx; i++ {
442 if a.prototype != nil {
443 if v := a.prototype.self.getIdx(valueInt(i), nil); v != nil {
444 arr[i] = exportValue(v, ctx)
445 }
446 }
447 }
448 v := item.value
449 if v != nil {
450 if prop, ok := v.(*valueProperty); ok {
451 v = prop.get(a.val)
452 }
453 arr[idx] = exportValue(v, ctx)
454 }
455 prevIdx = idx + 1
456 }
457 for i := prevIdx; i < a.length; i++ {
458 if a.prototype != nil {
459 if v := a.prototype.self.getIdx(valueInt(i), nil); v != nil {
460 arr[i] = exportValue(v, ctx)
461 }
462 }
463 }
464 return arr
465}
466
467func (a *sparseArrayObject) exportType() reflect.Type {
468 return reflectTypeArray

Callers

nothing calls this directly

Calls 5

valueIntTypeAlias · 0.85
exportValueFunction · 0.85
getMethod · 0.65
getIdxMethod · 0.65
putMethod · 0.45

Tested by

no test coverage detected