groups-of

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

npm install groups-of
4 downloads in the last day
15 downloads in the last week
72 downloads in the last month

groups-of

===========

Divides arrays into groups of a specified cardinality.

Build Status

Usage

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";

install

npm install groups-of

LICENSE

Grouper! http://wacohi1960.com/pht/3/grouper_fish_b.jpg

npm loves you