1 // Inspired by Underscore's groupBy:
2 // http://documentcloud.github.com/underscore/#groupBy
6 var callable = require('../../object/valid-callable')
7 , value = require('../../object/valid-value')
9 , forEach = Array.prototype.forEach, apply = Function.prototype.apply;
11 module.exports = function (cb/*, thisArg*/) {
14 (value(this) && callable(cb));
17 forEach.call(this, function (v) {
18 var key = apply.call(cb, this, arguments);
19 if (!r.hasOwnProperty(key)) r[key] = [];