forked from kriskbx/gitlab-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframeCollection.js
More file actions
executable file
·57 lines (44 loc) · 1.22 KB
/
frameCollection.js
File metadata and controls
executable file
·57 lines (44 loc) · 1.22 KB
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
52
53
54
55
56
57
const Base = require('./base');
const Frame = require('./frame');
const Fs = require('./../include/filesystem');
class frameCollection extends Base {
constructor(config) {
super(config);
this.frames =
Fs.readDir(config.frameDir)
.map(file => {
try {
return Frame.fromFile(this.config, Fs.join(this.config.frameDir, file));
} catch (e) {
console.log(e);
throw `Error parsing frame file: ${file}`
}
})
.filter(frame => frame);
}
sort(func) {
this.frames.sort(func);
return this;
}
filter(func) {
let arr = [];
this.frames.forEach(frame => {
if (frame.stop === false) {
return false;
}
if (func(frame)) {
arr.push(frame);
}
});
this.frames = arr;
return this;
}
forEach(iterator) {
let promise = this.parallel(this.frames, iterator);
return promise;
}
get length() {
return this.frames.length;
}
}
module.exports = frameCollection;