updeep-remeda/lib/map.js

18 lines
393 B
JavaScript
Raw Normal View History

2015-08-05 07:25:34 +00:00
import curry from 'lodash/function/curry';
import mapValues from 'lodash/object/mapValues';
import update from './update';
function map(iteratee, object) {
const updater = typeof iteratee === 'function' ?
iteratee :
val => update(iteratee, val);
if (Array.isArray(object)) {
return object.map(updater);
}
return mapValues(object, updater);
}
export default curry(map);