MCPcopy
hub / github.com/TomWright/dasel / arrayExprExecutor

Function arrayExprExecutor

execution/execute_array.go:11–40  ·  view source on GitHub ↗
(e ast.ArrayExpr)

Source from the content-addressed store, hash-verified

9)
10
11func arrayExprExecutor(e ast.ArrayExpr) (expressionExecutor, error) {
12 return func(ctx context.Context, options *Options, data *model.Value) (*model.Value, error) {
13 ctx = WithExecutorID(ctx, "arrayExpr")
14 res := model.NewSliceValue()
15
16 for _, expr := range e.Exprs {
17 el, err := ExecuteAST(ctx, expr, data, options)
18 if err != nil {
19 return nil, err
20 }
21
22 if el.IsSpread() {
23 if err := el.RangeSlice(func(_ int, value *model.Value) error {
24 if err := res.Append(value); err != nil {
25 return err
26 }
27 return nil
28 }); err != nil {
29 return nil, err
30 }
31 } else {
32 if err := res.Append(el); err != nil {
33 return nil, err
34 }
35 }
36 }
37
38 return res, nil
39 }, nil
40}
41
42func rangeExprExecutor(e ast.RangeExpr) (expressionExecutor, error) {
43 return func(ctx context.Context, options *Options, data *model.Value) (*model.Value, error) {

Callers 1

exprExecutorFunction · 0.85

Calls 6

NewSliceValueFunction · 0.92
WithExecutorIDFunction · 0.85
ExecuteASTFunction · 0.85
IsSpreadMethod · 0.80
RangeSliceMethod · 0.80
AppendMethod · 0.80

Tested by

no test coverage detected