mirror of
https://github.com/urbit/developers.urbit.org.git
synced 2024-09-11 21:57:16 +03:00
9 lines
292 B
JavaScript
9 lines
292 B
JavaScript
// Organises arrays into arrays of pairs
|
|
// Used mostly for TwoUps + content
|
|
export const pair = (arr) =>
|
|
arr.reduce(function (rows, key, index) {
|
|
return (
|
|
(index % 2 == 0 ? rows.push([key]) : rows[rows.length - 1].push(key)) &&
|
|
rows
|
|
);
|
|
}, []); |