Skip to content

Instantly share code, notes, and snippets.

@JoostKiens
Last active February 11, 2024 22:34
Show Gist options
  • Save JoostKiens/6bb77fb7aaf1462fa97b to your computer and use it in GitHub Desktop.
Save JoostKiens/6bb77fb7aaf1462fa97b to your computer and use it in GitHub Desktop.
Simple AMD module with basic localStorage utilities
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