updeep-remeda/lib/map.js
Aaron Jensen 1a1e2b313a Add u.map
2015-08-05 00:25:34 -07:00

18 lines
393 B
JavaScript

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);