Map source to target.
npm install -S @jswork/next-map-to
import '@jswork/next-map-to';
const obj = {
name: 'afeiship',
age: 18,
email: '[email protected]'
};
const ctx1 = {};
const ctx2 = {
set: function (key, value) {
this[`kv_${key}`] = value;
}
};
const res2 = nx.mapTo(obj, ctx);
/*
// res1
{
name: 'afeiship',
age: 18,
email: 'email@example.com'
}
// res2
{
set: [Function: set],
kv_name: 'afeiship',
kv_age: 18,
kv_email: 'email@example.com'
}
*/
Code released under the MIT license.