My node.js app receives two json objects from external API. The first object is weather data by days where the keys are unix timestamp:
{
1491368400: /*some data*/,
1491454800: /*some data*/,
1491541200: /*some data*/,
}
The second object is weather by hours for these days (if there are three days in object above, there are 3 * 24 keys in this object):
{
1491368400: /*some data*/,
1491372000: /*some data*/,
1491375600: /*some data*/,
.............................
/* there are 72 keys, 24 for every proper day from object above */
}
I need to combine these two objects: take data from second object with hours and calculate average values for each day from first object and put these values into the first object. I think it would be good to do it with Transform Stream, but have no idea how to do it properly. I need just a schema how to do it, not detailed solution.
UPDATE
The main thing I want to know is how to merge two objects without putting much pressure on event loop.