-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathContext.ts
More file actions
31 lines (28 loc) · 686 Bytes
/
Context.ts
File metadata and controls
31 lines (28 loc) · 686 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
type Context = {
runtimeCtx: object,
dayChecks: object,
debugMsg: (string) => void
}
const self = this;
const Context: Context = {
runtimeCtx: self,
dayChecks: {
everyday: () => true,
weekDay: () => !isWeekEnd(new Date()),
lastWeekDayOfMonth: () => isLastWeekDayOfMonth(new Date()),
},
debugMsg(text) {
console.log(`DEBUG_MSG: ${text}`)
}
}
function SetContext(config: Context) {
if (config.dayChecks) {
Context.dayChecks = config.dayChecks
}
if (config.debugMsg) {
Context.debugMsg = config.debugMsg
}
if (config.runtimeCtx) {
Context.runtimeCtx = config.runtimeCtx
}
}