UNPKG

module-composer

Version:

Bring order to chaos. Level up your JS application architecture with Module Composer, a tiny but powerful module composition utility based on functional dependency injection.

13 lines (10 loc) 392 B
const util = require('../core/util'); const precompose = () => ({ target, options }) => { const { functionAlias } = options; const newTarget = util.flatMapKeys(target, (val, key) => { const aliasKeys = functionAlias.map(([from, to]) => key.replace(from, to)); return [key, ...aliasKeys]; }); return { target: newTarget }; }; module.exports = { precompose };