Last active
February 11, 2024 22:34
-
-
Save JoostKiens/6bb77fb7aaf1462fa97b to your computer and use it in GitHub Desktop.
Simple AMD module with basic localStorage utilities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function () { | |
'use strict'; | |
function removeItem(itemKey) { | |
localStorage.removeItem(itemKey); | |
} | |
function getItem(itemKey) { | |
return JSON.parse(localStorage.getItem(itemKey)); | |
} | |
function setItem(itemKey, data) { | |
localStorage.setItem(itemKey, JSON.stringify(data)); | |
} | |
return { | |
removeItem: removeItem, | |
getItem: getItem, | |
setItem: setItem | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment