mirror of
https://github.com/urbit/developers.urbit.org.git
synced 2024-10-26 15:49:50 +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
|
|
);
|
|
}, []); |