-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathbuild.js
51 lines (43 loc) · 943 Bytes
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* Expose `Build`
*/
module.exports = Build;
/**
* Initialize `Build` with `components`.
*
* @param {Array} components
* @api private
*/
function Build(components){
this.components = components;
}
/**
* Call `fn(file, conf)` for each file of `type`.
*
* @param {String} type
* @param {Function} fn
* @api private
*/
Build.prototype.each = function(type, fn){
for (var i = 0; i < this.components.length; ++i) {
var all = this.components[i][type] || [];
for (var j = 0; j < all.length; ++j) {
fn(all[j], this.components[i]);
}
}
};
/**
* Map files of `type` with `fn(file, conf)`.
*
* @param {String} type
* @param {Function} fn
* @api private
*/
Build.prototype.map = function(type, fn){
for (var i = 0; i < this.components.length; ++i) {
var all = this.components[i][type] || [];
for (var j = 0; j < all.length; ++j) {
all[j] = fn(all[j], this.components[i]);
}
}
};