resolve-resolve.js 589 B

123456789101112131415161718192021
  1. "use strict";
  2. var toArray = require("es5-ext/array/to-array")
  3. , isValue = require("es5-ext/object/is-value")
  4. , callable = require("es5-ext/object/valid-callable");
  5. var slice = Array.prototype.slice, resolveArgs;
  6. resolveArgs = function (args) {
  7. return this.map(function (resolve, i) {
  8. return resolve ? resolve(args[i]) : args[i];
  9. }).concat(slice.call(args, this.length));
  10. };
  11. module.exports = function (resolvers) {
  12. resolvers = toArray(resolvers);
  13. resolvers.forEach(function (resolve) {
  14. if (isValue(resolve)) callable(resolve);
  15. });
  16. return resolveArgs.bind(resolvers);
  17. };