Adding splat[] short hand to collect,eval,map,omit,path,pick

This commit is contained in:
Mike Farah
2024-06-16 10:22:42 +10:00
parent 45eda8dbae
commit f1964dece0
8 changed files with 77 additions and 8 deletions
+19
View File
@@ -15,6 +15,15 @@ var mapOperatorScenarios = []expressionScenario{
"D0, P[], (!!seq)::[6, 7, 8]\n",
},
},
{
skipDoc: true,
document: `[1,2]`,
expression: `map(. + 1)[]`,
expected: []string{
"D0, P[0], (!!int)::2\n",
"D0, P[1], (!!int)::3\n",
},
},
{
description: "Map array",
document: `[1,2,3]`,
@@ -33,6 +42,16 @@ var mapOperatorScenarios = []expressionScenario{
"D0, P[], (!!map)::{x: 11, y: 21, z: 31}\n",
},
},
{
description: "map values splat",
skipDoc: true,
document: `{a: 1, b: 2}`,
expression: `map_values(. + 1)[]`,
expected: []string{
"D0, P[a], (!!int)::2\n",
"D0, P[b], (!!int)::3\n",
},
},
{
description: "Map object values",
document: `{a: 1, b: 2, c: 3}`,