This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var x = [ {node: "ip2", app: "dbsyncer", containerId: "1234"}, | |
{node: "ip2", app: "logforwa", containerId: "3423"}, | |
{node: "ip4", app: "dbsyncer", containerId: "2213"}, | |
{node: "ip4", app: "logforwa", containerId: "3434"} ] | |
var newObj = {}; | |
x.forEach(function (item) { | |
newObj[item.node] = newObj[item.node] || []; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mapValues(obj, fn) { | |
return Object.keys(obj).reduce((result, key) => { | |
result[key] = fn(obj[key], key); | |
return result; | |
}, {}); | |
} | |
function pick(obj, fn) { | |
return Object.keys(obj).reduce((result, key) => { | |
if (fn(obj[key])) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
const counter = (state = { value: 0 }, action) => { | |
switch (action.type) { | |
case 'INCREMENT': | |
return { value: state.value + 1 }; | |
case 'DECREMENT': | |
return { value: state.value - 1 }; | |
default: | |
return state; |