Iterates over an object.
Calls the given callback function with each value and key in the object. The callback receives the value as the first argument, and key as the second.
function objectForEach(obj: object, cb: function): object
obj:object
The object to iterate over.
cb:function
The callback function.
A shallow copy of the given object.
import { objectForEach } from '@deskpro/js-utils/dist/objects';
const values = {
name: 'item',
title: 'foo'
};
let actual = {};
objectForEach(values, (val, key) => {
actual[key] = val;
});
console.log(actual);
// Outputs:
// { name: 'item', title: 'foo' }