Chore: throw error if undefined operatorId
This commit is contained in:
parent
8d6ed7c2a3
commit
35224e415c
2 changed files with 29 additions and 19 deletions
|
|
@ -1,9 +1,15 @@
|
|||
const _ = require('lodash/fp')
|
||||
const state = require('./state')
|
||||
|
||||
const getTimestamp = (operatorId) => state.settingsCache[operatorId] ? state.settingsCache[operatorId].timestamp : null
|
||||
const getTimestamp = (operatorId) => {
|
||||
if (!operatorId) throw new Error('operatorId must not be nil or empty')
|
||||
return state.settingsCache[operatorId] ? state.settingsCache[operatorId].timestamp : null
|
||||
}
|
||||
|
||||
const getCache = (operatorId) => state.settingsCache[operatorId] ? state.settingsCache[operatorId].cache : null
|
||||
const getCache = (operatorId) => {
|
||||
if (!operatorId) throw new Error('operatorId must not be nil or empty')
|
||||
return state.settingsCache[operatorId] ? state.settingsCache[operatorId].cache : null
|
||||
}
|
||||
|
||||
const setTimestamp = (operatorId, newTimestamp) => {
|
||||
state.settingsCache = _.set([operatorId, 'timestamp'], newTimestamp, state.settingsCache)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue