tessl install tessl/npm-store@2.0.0A localStorage wrapper for all browsers without using cookies or flash, providing persistent client-side storage with automatic fallback and plugin architecture
Agent Success
Agent success rate when using this tile
75%
Improvement
Agent success rate improvement when using this tile compared to baseline
0.96x
Baseline
Agent success rate without this tile
78%
A utility that safely reads and normalizes data stored by various systems in localStorage. The tool must handle data that may have been stored using different serialization approaches, including raw strings, pre-stringified JSON, and improperly formatted values.
@generates
/**
* Safely retrieves a value from localStorage with automatic deserialization.
* Handles raw strings, JSON-stringified values, and malformed data.
*
* @param {string} key - The key to retrieve
* @param {*} defaultValue - Optional default value if key doesn't exist
* @returns {*} The retrieved and deserialized value, or defaultValue if not found
*/
function safeGet(key, defaultValue) {
// IMPLEMENTATION HERE
}
/**
* Stores a value in localStorage with automatic serialization.
*
* @param {string} key - The key to store under
* @param {*} value - The value to store
* @returns {*} The stored value
*/
function safeSet(key, value) {
// IMPLEMENTATION HERE
}
/**
* Removes a value from localStorage.
*
* @param {string} key - The key to remove
*/
function safeRemove(key) {
// IMPLEMENTATION HERE
}
module.exports = {
safeGet,
safeSet,
safeRemove
};Provides cross-browser local storage support with automatic serialization and deserialization.