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

Function ExampleRuntime_ExportTo_arrayLikeToSlice

object_test.go:373–395  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

371}
372
373func ExampleRuntime_ExportTo_arrayLikeToSlice() {
374 vm := New()
375 v, err := vm.RunString(`
376 ({
377 length: 3,
378 0: 1,
379 1: 2,
380 2: 3
381 });
382 `)
383 if err != nil {
384 panic(err)
385 }
386
387 var arr []int
388 err = vm.ExportTo(v, &arr)
389 if err != nil {
390 panic(err)
391 }
392
393 fmt.Println(arr)
394 // Output: [1 2 3]
395}
396
397func TestExportArrayToArrayMismatchedLengths(t *testing.T) {
398 vm := New()

Callers

nothing calls this directly

Calls 3

NewFunction · 0.85
RunStringMethod · 0.80
ExportToMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…