removed the temp len binding as the issue was fixed in goja#521

This commit is contained in:
Gani Georgiev
2023-06-21 13:40:59 +03:00
parent 93606c6647
commit fc311a8d28
4 changed files with 585 additions and 203 deletions

View File

@@ -79,24 +79,6 @@ func baseBinds(vm *goja.Runtime) {
return dest, nil
})
// temporary helper to properly return the length of an array
// see https://github.com/dop251/goja/issues/521
vm.Set("len", func(val any) int {
rv := reflect.ValueOf(val)
rk := rv.Kind()
if rk == reflect.Ptr {
rv = rv.Elem()
rk = rv.Kind()
}
if rk == reflect.Slice || rk == reflect.Array {
return rv.Len()
}
return 0
})
vm.Set("DynamicModel", func(call goja.ConstructorCall) *goja.Object {
shape, ok := call.Argument(0).Export().(map[string]any)
if !ok || len(shape) == 0 {