MCPcopy Create free account
hub / github.com/codecombat/codecombat / normalizeCacheEntry

Function normalizeCacheEntry

app/lib/user-utils.js:107–118  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

105}
106
107function normalizeCacheEntry (value) {
108 if (value == null) { return null }
109 if (typeof value === 'number') {
110 return { first: value, last: value, count: 1 }
111 }
112 if (value.first == null) { return null }
113 return {
114 first: typeof value.first === 'number' ? value.first : new Date(value.first).getTime(),
115 last: value.last != null ? (typeof value.last === 'number' ? value.last : new Date(value.last).getTime()) : undefined,
116 count: value.count,
117 }
118}
119
120function readActivityFromCache (userId, activityName) {
121 return normalizeCacheEntry(readActivityStatusCache(userId)[activityName])

Callers 1

readActivityFromCacheFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected