]> gerrit.simantics Code Review - simantics/district.git/blobdiff - 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
diff --git a/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 b/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
new file mode 100644 (file)
index 0000000..fbb178c
--- /dev/null
@@ -0,0 +1,23 @@
+// Inspired by Underscore's groupBy:
+// http://documentcloud.github.com/underscore/#groupBy
+
+'use strict';
+
+var callable = require('../../object/valid-callable')
+  , value    = require('../../object/valid-value')
+
+  , forEach = Array.prototype.forEach, apply = Function.prototype.apply;
+
+module.exports = function (cb/*, thisArg*/) {
+       var r;
+
+       (value(this) && callable(cb));
+
+       r = {};
+       forEach.call(this, function (v) {
+               var key = apply.call(cb, this, arguments);
+               if (!r.hasOwnProperty(key)) r[key] = [];
+               r[key].push(v);
+       }, arguments[1]);
+       return r;
+};