build.js 634 B

12345678910111213141516171819202122232425262728
  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
  19. .sort()
  20. .map(function(name) {
  21. return sources[name];
  22. })
  23. .join('\n');
  24. }