Chore: throw error if undefined operatorId

This commit is contained in:
csrapr 2021-03-18 18:14:19 +00:00 committed by Josh Harvey
parent 8d6ed7c2a3
commit 35224e415c
2 changed files with 29 additions and 19 deletions

View file

@ -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)