Require a module and apply the export if it is a function.
npm install reapply --save
var reapply = require('reapply')
reapply(['%s world', 'hello'], 'format')
//=> hello world
modules.forEach(reapply([app]))
for the above example, consider that a developer may want to bootstrap an application by applying many "middleware" functions to a given
app
object. Each module exports a function that takes anapp
parameter likemodule.exports = function (app) { app.use(…) }
.
- Supports partial application.
- Supports function application with parameters.
parameters: (Array)
parameters to pass to applied function.moduleId: (String)
module id to pass torequire
.
(*)
returns result of function application.
- If you find yourself wanting to map over a list with
reapply
you might be interested in reapply-list.
SEE: contributing.md