felixgirault/essence.js

View on GitHub
src/presenters/mapResponseProps.js

Summary

Maintainability
A
0 mins
Test Coverage
import {reduce} from 'lodash';



/**
 *
 */
const mapProp = (res, to, from) =>
    res.has(from)
        ? res.withProp(to, res.get(from))
        : res;



/**
 *
 */
export default function mapResponseProps(mapping, {req, res}) {
    return {
        req,
        res: reduce(mapping, mapProp, res)
    };
}