Context
A $array definition provides one pipeline per array position. In reverse, values beyond the number of defined pipelines are currently ignored:
const def = {
$array: ["title", "name"],
}
// Reverse input
["A title", "A name", "Extra value"]
// The third value has no destination and is dropped.
This behavior is reasonable with the current definition because no destination is specified. However, the language could allow the definition to provide an explicit destination for remaining values.
Possible enhancement
Add a rest pipeline to $array, conceptually similar to:
{
$array: ["title", "name"],
rest: "extras[]",
}
In reverse, values after the defined positional pipelines would be passed to the rest pipeline. The exact property name and syntax are open for discussion.
Questions
- Should the rest pipeline receive the remaining values as one array or run once per value?
- What should it do in the array-building direction?
- Should a rest pipeline also support
$flip?
- How should it interact with missing positional values and
$noDefaults?
This should remain explicit: extra values should not be preserved implicitly when the definition provides no destination.
Context
A
$arraydefinition provides one pipeline per array position. In reverse, values beyond the number of defined pipelines are currently ignored:This behavior is reasonable with the current definition because no destination is specified. However, the language could allow the definition to provide an explicit destination for remaining values.
Possible enhancement
Add a rest pipeline to
$array, conceptually similar to:In reverse, values after the defined positional pipelines would be passed to the rest pipeline. The exact property name and syntax are open for discussion.
Questions
$flip?$noDefaults?This should remain explicit: extra values should not be preserved implicitly when the definition provides no destination.