mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-25 16:47:58 -05:00
15 lines
383 B
CoffeeScript
15 lines
383 B
CoffeeScript
module.exports.load = (key) ->
|
|
s = localStorage.getItem(key)
|
|
return null unless s
|
|
try
|
|
value = JSON.parse(s)
|
|
return value
|
|
catch SyntaxError
|
|
console.warn('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
|