MCPcopy Create free account
hub / github.com/ptmt/react-native-macos / groupByEveryN

Function groupByEveryN

Libraries/Utilities/groupByEveryN.js:30–50  ·  view source on GitHub ↗
(array: Array<T>, n: number)

Source from the content-addressed store, hash-verified

28'use strict';
29
30function groupByEveryN<T>(array: Array<T>, n: number): Array<Array<?T>> {
31 var result = [];
32 var temp = [];
33
34 for (var i = 0; i < array.length; ++i) {
35 if (i > 0 && i % n === 0) {
36 result.push(temp);
37 temp = [];
38 }
39 temp.push(array[i]);
40 }
41
42 if (temp.length > 0) {
43 while (temp.length !== n) {
44 temp.push(null);
45 }
46 result.push(temp);
47 }
48
49 return result;
50}
51
52module.exports = groupByEveryN;

Callers 2

CameraRollView.jsFile · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…