Let's say I have an arbitrary number of arrays that are the same length. I want to merge them together into another array.
What I mean by merge is to combine each value of the arrays together into the output array.
Can I get a function merge(...arrays)
that can do this?
Type Definition (might be wrong): <T extends Array<U>, U>(...arr: T[]) => [...T][]
merge([A, B], [C, D])
→ [[A, C], [B, D]]
Examples:
merge([1, 2, 3], [10, 20, 30])
→[[1, 10], [2, 20], [3, 30]]
merge([1, 2, 3])
→[[1], [2], [3]]
merge([1, "", {}], [17, { a: 1 }, "a"])
→[[1, 17], ["", { a: 1 }], [{}, "a"]]
merge([])
→[]
EDIT: Also, please provide a TypeScript Type definition for the function.