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
43 lines (33 loc) · 1010 Bytes
/
frameCollection.js
File metadata and controls
43 lines (33 loc) · 1010 Bytes
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
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);
}
filter(func) {
let arr = [];
this.frames.forEach(file => {
let frame = Frame.fromFile(this.config, Fs.join(this.config.frameDir, file));
if (frame.stop === false) {
return;
}
if (func(frame)) {
arr.push(file);
}
});
this.frames = arr;
}
forEach(iterator) {
return this.parallel(this.frames, (file, done) => {
let frame = Frame.fromFile(this.config, Fs.join(this.config.frameDir, file));
if (frame.stop === false) return done();
iterator(frame, done);
});
}
get length() {
return this.frames.length;
}
}
module.exports = frameCollection;