mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
13 lines
355 B
CoffeeScript
13 lines
355 B
CoffeeScript
|
module.exports.loadObjectFromStorage = (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.saveObjectToStorage = (key, value) ->
|
||
|
s = JSON.stringify(value)
|
||
|
localStorage.setItem(key, s)
|