pragmatic-fp-ts
Version:
Opinionated functional programming library with easy use in mind
16 lines (15 loc) • 453 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.mapKeys = void 0;
const main_1 = require("./main");
function mapKeys(fn, dict) {
if (arguments.length === 1) {
return (_dict) => mapKeys(fn, _dict);
}
const d = dict || {};
return Object.keys(d || {}).reduce((accum, key) => {
accum[(0, main_1.getValue)(fn(key))] = d[key];
return accum;
}, {});
}
exports.mapKeys = mapKeys;