Skip to content

Commit 4b6cb4e

Browse files
committed
update array object
1 parent 90853f7 commit 4b6cb4e

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

bridge.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ func (b *Bridge) addValues() {
116116
"Object": &object{name: "Object", new: func(args []interface{}) interface{} {
117117
return &object{name: "ObjectInner", props: map[string]interface{}{}}
118118
}},
119-
"Array": propObject("Array", nil),
120-
"Uint8Array": typedArray,
119+
"Array": arrayObject("Array"),
120+
"Uint8Array": arrayObject("Uint8Array"),
121121
"process": propObject("process", nil),
122122
"Date": &object{name: "Date", new: func(args []interface{}) interface{} {
123123
t := time.Now()
@@ -432,14 +432,16 @@ type array struct {
432432
buf []byte
433433
}
434434

435-
var typedArray = &object{
436-
name: "TypedArray",
437-
new: func(args []interface{}) interface{} {
438-
l := int(args[0].(float64))
439-
return &array{
440-
buf: make([]byte, l, l),
441-
}
442-
},
435+
func arrayObject(name string) *object {
436+
return &object{
437+
name: name,
438+
new: func(args []interface{}) interface{} {
439+
l := int(args[0].(float64))
440+
return &array{
441+
buf: make([]byte, l, l),
442+
}
443+
},
444+
}
443445
}
444446

445447
// TODO make this a wrapper that takes an inner `this` js object

0 commit comments

Comments
 (0)