codecombat/app/lib/storage.coffee
2014-01-26 14:44:08 -08:00

15 lines
No EOL
387 B
CoffeeScript

module.exports.load = (key) ->
s = localStorage.getItem(key)
return null unless s
try
value = JSON.parse(s)
return value
catch SyntaxError
console.warning('error loading from storage', key)
return null
module.exports.save = (key, value) ->
s = JSON.stringify(value)
localStorage.setItem(key, s)
module.exports.remove = (key) -> localStorage.removeItem key