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
·48 lines (38 loc) · 1.06 KB
/
frameCollection.js
File metadata and controls
executable file
·48 lines (38 loc) · 1.06 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
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) {
return false;
}
})
.filter(frame => frame);
}
filter(func) {
let arr = [];
this.frames.forEach(frame => {
if (frame.stop === false) {
return false;
}
if (func(frame)) {
arr.push(frame);
}
this.frames = arr;
});
}
forEach(iterator) {
let promise = this.parallel(this.frames, iterator);
return promise;
}
get length() {
return this.frames.length;
}
}
module.exports = frameCollection;