build.js 617 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. var fs = require('fs');
  3. var dependencies = require('./lib/dependencies.js');
  4. var internals = require('./lib/internals.js');
  5. var sources = require('./lib/sources.js');
  6. module.exports = build;
  7. function build(functions) {
  8. var fns = [];
  9. functions = functions.filter(function (fn) {
  10. return !internals[fn];
  11. });
  12. for (var i = 0; i < functions.length; i++) {
  13. if (fns.indexOf(functions[i]) === -1) {
  14. fns.push(functions[i]);
  15. functions.push.apply(functions, dependencies[functions[i]]);
  16. }
  17. }
  18. return fns.sort().map(function (name) {
  19. return sources[name];
  20. }).join('\n');
  21. }