Lewerow/Zurvan

View on GitHub
detail/utils/APICreator.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
'use strict';
function exportFunction(exportedObject, functionName) {
  return function() {
    return exportedObject[functionName].apply(
      exportedObject,
      [].splice.call(arguments, 0)
    );
  };
}

function createAPI(exportedObject, functionNames) {
  return functionNames.reduce(function(api, name) {
    api[name] = exportFunction(exportedObject, name);
    return api;
  }, {});
}

module.exports.createAPI = createAPI;