Add partition function
#452
aleclarson
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
|
Radashi example with import { group } from "radashi";
const numbers = [5, 6, 7, 8, 9];
const { even = [], odd = [] } = group(numbers, (it) =>
it % 2 === 0 ? "even" : "odd",
);It also guarantees arrays to exist even if one or both are empty. Maybe not as readable as |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Inspired by the Deno stdlib: https://github.com/denoland/std/blob/e8e47da19e2393da4f58b93d7d8377b83698c6f4/collections/partition.ts#L1
Nice thing about this, versus Radashi's
group(), is two fold:This would make
partitiona nice addition.Concerns
groupandpartitiontoo confusing?partitionnot a clear enough name?Feel free to voice your opinions below. ✌️
Beta Was this translation helpful? Give feedback.
All reactions