Right now, the source argument passed to the mapper function is not the actual original source argument the user passed to mapObject, but the "owner" object of the key/value pair for the current iteration.
Example:
const { default: mapObject } = await import('./index.js');
const subject = { nestedA: { one: 1, two: 2 }, nestedB: { three: 3, four: 4 } };
const mapper = (key, value, source) => source !== subject ? [key + '_different', value] : [key + '_same', value];
console.log(mapObject(subject, mapper, { deep: true }));
{
nestedA_same: { one_different: 1, two_different: 2 },
nestedB_same: { three_different: 3, four_different: 4 }
}
Notice source is only equal to subject for the top level keys.
Fixing this would be a breaking change, so should probably be released as v6.0.0?
Right now, the
sourceargument passed to themapperfunction is not the actual originalsourceargument the user passed tomapObject, but the "owner" object of the key/value pair for the current iteration.Example:
Notice
sourceis only equal tosubjectfor the top level keys.Fixing this would be a breaking change, so should probably be released as
v6.0.0?