var Adaptor = { foo: function(message) { console.log(message); }, bar: function() { return 'baz' } } function getHandlers(adaptor) { return Object.keys(adaptor).map(function(key) { return adaptor[key] }) } function Inject(adaptor, f) { // Get the functions for all the keys in the adaptor // [[Function], [Function], ...] var handlers = getHandlers(adaptor) // Create a new Function with arguments in order and matching the names // of the adaptor. // // new Function('foo', 'bar', 'foo(bar())') // // Then call the new function with the handlers in order. return new Function(Object.keys(adaptor), f) .apply(null, handlers) } Inject(Adaptor, 'foo(bar())') // bar