mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 14:43:33 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
37 lines
1013 B
TypeScript
37 lines
1013 B
TypeScript
// Loaded from https://deno.land/x/ramda@v0.27.2/source/mapObjIndexed.js
|
|
|
|
|
|
import _curry2 from './internal/_curry2.js';
|
|
import _reduce from './internal/_reduce.js';
|
|
import keys from './keys.js';
|
|
|
|
|
|
/**
|
|
* An Object-specific version of [`map`](#map). The function is applied to three
|
|
* arguments: *(value, key, obj)*. If only the value is significant, use
|
|
* [`map`](#map) instead.
|
|
*
|
|
* @func
|
|
* @memberOf R
|
|
* @since v0.9.0
|
|
* @category Object
|
|
* @sig ((*, String, Object) -> *) -> Object -> Object
|
|
* @param {Function} fn
|
|
* @param {Object} obj
|
|
* @return {Object}
|
|
* @see R.map
|
|
* @example
|
|
*
|
|
* const xyz = { x: 1, y: 2, z: 3 };
|
|
* const prependKeyAndDouble = (num, key, obj) => key + (num * 2);
|
|
*
|
|
* R.mapObjIndexed(prependKeyAndDouble, xyz); //=> { x: 'x2', y: 'y4', z: 'z6' }
|
|
*/
|
|
var mapObjIndexed = _curry2(function mapObjIndexed(fn, obj) {
|
|
return _reduce(function(acc, key) {
|
|
acc[key] = fn(obj[key], key, obj);
|
|
return acc;
|
|
}, {}, keys(obj));
|
|
});
|
|
export default mapObjIndexed;
|