update array object

pull/4/head
vedhavyas 2020-01-05 18:00:02 +01:00
parent 90853f742d
commit 4b6cb4e86f
No known key found for this signature in database
GPG Key ID: 317BF0923E3EB7E5
1 changed files with 12 additions and 10 deletions

View File

@ -116,8 +116,8 @@ func (b *Bridge) addValues() {
"Object": &object{name: "Object", new: func(args []interface{}) interface{} { "Object": &object{name: "Object", new: func(args []interface{}) interface{} {
return &object{name: "ObjectInner", props: map[string]interface{}{}} return &object{name: "ObjectInner", props: map[string]interface{}{}}
}}, }},
"Array": propObject("Array", nil), "Array": arrayObject("Array"),
"Uint8Array": typedArray, "Uint8Array": arrayObject("Uint8Array"),
"process": propObject("process", nil), "process": propObject("process", nil),
"Date": &object{name: "Date", new: func(args []interface{}) interface{} { "Date": &object{name: "Date", new: func(args []interface{}) interface{} {
t := time.Now() t := time.Now()
@ -432,14 +432,16 @@ type array struct {
buf []byte buf []byte
} }
var typedArray = &object{ func arrayObject(name string) *object {
name: "TypedArray", return &object{
new: func(args []interface{}) interface{} { name: name,
l := int(args[0].(float64)) new: func(args []interface{}) interface{} {
return &array{ l := int(args[0].(float64))
buf: make([]byte, l, l), return &array{
} buf: make([]byte, l, l),
}, }
},
}
} }
// TODO make this a wrapper that takes an inner `this` js object // TODO make this a wrapper that takes an inner `this` js object