Closed mikicho closed 2 years ago
@mikicho If I understand this right, the output of your example would be {a: 1}
-> {a: 2}
-> {a: 1}
, because if we index off the end of the array we will repeat the first element. I think it maybe makes more sense to repeat the last element, if we repeat. Or maybe the alt version allows you to specify tuples of [count, factory]
as spread args? So it would look like:
buildList([1, { a: 2 }], [2, { a: 1 }])
or some sort of chained builder syntax. I'm curious what your thoughts are.
Also, can you please add test(s) around the new buildList functionality you'd like to see? And please use ReadonlyArray<>
whenever possible, so if someone happens to have a ReadonlyArray to pass into buildList, they don't have to cast it to mutable. Thanks!
I agree. I thought I'd have time to invest in this PR. but unfortunately, I can't. I'm closing this for now.
WDYT?
So instead of:
We can do: