]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/group.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / node-gyp / node_modules / path-array / node_modules / array-index / node_modules / es6-symbol / node_modules / es5-ext / array / # / group.js
1 // Inspired by Underscore's groupBy:
2 // http://documentcloud.github.com/underscore/#groupBy
3
4 'use strict';
5
6 var callable = require('../../object/valid-callable')
7   , value    = require('../../object/valid-value')
8
9   , forEach = Array.prototype.forEach, apply = Function.prototype.apply;
10
11 module.exports = function (cb/*, thisArg*/) {
12         var r;
13
14         (value(this) && callable(cb));
15
16         r = {};
17         forEach.call(this, function (v) {
18                 var key = apply.call(cb, this, arguments);
19                 if (!r.hasOwnProperty(key)) r[key] = [];
20                 r[key].push(v);
21         }, arguments[1]);
22         return r;
23 };