-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
54 lines (40 loc) · 928 Bytes
/
index.js
File metadata and controls
54 lines (40 loc) · 928 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
44
45
46
47
48
49
50
51
52
53
54
'use strict'
const path = require('path')
function applyStats (state, pack, entry, ext) {
const opKeys = Object.keys(state.ops)
opKeys.forEach(ok => {
const op = state.ops[ok]
const met = require(path.join(__dirname, 'ops', op.op))
if (!met.calc) {
return
}
pack[ok] = met.calc(op, pack[ok], entry, ext)
})
}
function tallyStats (state, pack) {
const opKeys = Object.keys(state.ops)
opKeys.forEach(ok => {
const op = state.ops[ok]
const met = require(path.join(__dirname, 'ops', op.op))
if (!pack[ok]) {
return
}
if (met.tally) {
pack[ok] = met.tally(op, pack[ok])
}
pack[ok] = pack[ok].res
})
}
const DEFAULT_TIMEFRAMES = [
['5m', '0 */5 * * * *'],
['30m', '0 */30 * * * *'],
['3h', '0 0 */3 * * *'],
['1D', '0 0 0 * * *']
]
module.exports = {
defaults: {
timeframes: DEFAULT_TIMEFRAMES
},
applyStats,
tallyStats
}