JSFiddle - React, Tailwind, and code Playground
by kentaromiura
JavaScript
Array.implement('paginate', function(count){
var result = [], pageIndex = -1
for(var i=0, max = this.length; i<max; i++){
if (i%count==0){
pageIndex++
result.push([])
}
result[pageIndex].push(this[i])
}
return result;
});
workondata = function(data){
console.log(data)
}
var data = [1,2,3,4].paginate(2);
function process(data, index, delay){
workondata(data[index]);
if( data.length-index >1 ) setTimeout(
function(){
process(data, index +1, delay)
},
delay
);
}
process(data, 0, 1000)