Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function groupBy(array, key) {
- return array.reduce(function(result, currentValue) {
- (result[currentValue[key]] = result[currentValue[key]] || []).push(currentValue);
- return result;
- }, {});
- }
- // counter
- function groupBy(array, key) {
- return array.reduce(function(result, currentValue) {
- var group = currentValue[key];
- if (!result[group]) {
- result[group] = { count: 0, values: [] };
- }
- result[group].count++;
- result[group].values.push(currentValue);
- return result;
- }, {});
- }
- // inet_ntoa
- function numberToIp(number) {
- var parts = [];
- for (var i = 3; i >= 0; i--) {
- parts[i] = number & 255;
- number = number >> 8;
- }
- return parts.join('.');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement