ObjectLiteralExpression builds `{ k: v, ... }` in expression position.
(expr *ObjectLiteralExpression)
| 939 | |
| 940 | // ObjectLiteralExpression builds `{ k: v, ... }` in expression position. |
| 941 | func (b *Bindings) ObjectLiteralExpression(expr *ObjectLiteralExpression) (*goja.Object, error) { |
| 942 | objF, err := b.f("objectLiteralExpression") |
| 943 | if err != nil { |
| 944 | return nil, err |
| 945 | } |
| 946 | props := make([]interface{}, 0, len(expr.Properties)) |
| 947 | for _, p := range expr.Properties { |
| 948 | v, err := b.PropertyAssignment(p) |
| 949 | if err != nil { |
| 950 | return nil, fmt.Errorf("object literal property %q: %w", p.Name, err) |
| 951 | } |
| 952 | props = append(props, v) |
| 953 | } |
| 954 | res, err := objF(goja.Undefined(), b.vm.NewArray(props...)) |
| 955 | if err != nil { |
| 956 | return nil, xerrors.Errorf("call objectLiteralExpression: %w", err) |
| 957 | } |
| 958 | return res.ToObject(b.vm), nil |
| 959 | } |
| 960 | |
| 961 | // PropertyAssignment builds `<name>: <initializer>` for an |
| 962 | // ObjectLiteralExpression child. |
no test coverage detected