Closed josephjclark closed 3 months ago
I am not familiar with a key word bin
. But from what i have understood so far, We need to a util helper that will sort an array of objects by a key path. The suggested signature bin(pathToArray, keyPath)
.
If this is the correct assessment then my suggestion is we don't use the word bin, We should use something very specific to what this function is doing. Eg sortByKey or sortBy. I personally like the word groupBy
I will sync with @josephjclark to get his opinion as well
Oh man groupBy is a way better name 🤦🤦🤦
Or maybe just group
?
For me sort
just means "change the order of an array", whereas this function is "organise this data into groups"
@josephjclark should this be an operation or a util helper ?
hey @mtuchi @josephjclark can we close this issue out? I see the PR has been merged
EDIT: forget
bin
, this isgroup
The
bin
operation takes an array of data and sorts it into "bins".It works like
each
, taking an array or jsonpath as an argument, and iterating over each item with scoped data.The return value of the function is the name of the bin to add the item to.
Bins are added as keys to the state object
For example, for this state
Calling this:
Results in this state: