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