node package manager

Introducing npm Enterprise add-ons. Integrate third-party dev tools into npm…

groups-of

Divides arrays or strings into sub-groups of a given cardinality

groups-of

===========

Divides arrays into groups of a specified cardinality.

var groupsOf = require('groups-of');
var array = [3,4,5,6,7];
 
groupsOf(3, array, function (group) {
  console.log('the group is %s', group);
});
 
// Outputs: 
// the group is [3,4,5] 
// the group is [6,7] 

Even works with strings:

var string = "oh say can you say";
 
groupsOf(8, string, function (group) {
  console.log('the group is %s', group);
})
 
// Outputs: 
// the group is "oh say c"; 
// the group is "an you s"; 
// the group is "ay"; 
npm install groups-of

LICENSE