Mapper.map proposal
Here are two uses of iterating objects currently.
Object.keys(record.dataValues).map((key) => {
const row = record.dataValues[key]
..etc
})
for (const key in record.dataValues) {
const row = record.dataValues[key]
if (row === null) row = ''
record.dataValues[key] = row
}
Both methods work fine but require extra scaffolding that gets repetitive. The whole point of Mapper is to help with this. Also, to operate more like the work on Arrays happens (which is much smoother).
Here is my proposed usage.
const someObject = { foo: 'baz', two: 2, three: null }
Mapper.getInstance(someObject).map((value, key) => {
if (value === null) value = ''
return value
})
console.log(someObject)
// { foo: 'baz', two: 2, three: '' }
Where the returned value will be written to the current property of the object.
This is open to suggestions.