on master help sign in
lib: add pair to library
b0ed348Matilde Park
lib/lib.js+9
@@ -287,3 +287,12 @@ export function getOpenGrantsCount() {
287 }, 0);
287 }, 0);
288 return count;
288 return count;
289}
289}
290+
291+// Groups arrays into an array of arrays with 2 members
292+export const pair = (arr) =>
293+ arr.reduce(function (rows, key, index) {
294+ return (
295+ (index % 2 == 0 ? rows.push([key]) : rows[rows.length - 1].push(key)) &&
296+ rows
297+ );
298+ }, []);