CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-store

tessl install tessl/npm-store@2.0.0

A 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%

task.mdevals/scenario-9/

Legacy Data Migration Tool

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.

Capabilities

Reads values with different serialization formats

  • It retrieves a value that was stored as a raw string (not JSON-stringified) @test
  • It retrieves a value that was stored as JSON-stringified data @test
  • It retrieves a value that was stored as a double-stringified JSON (accidentally stringified twice) @test

Handles malformed or corrupted data gracefully

  • It handles values with invalid JSON syntax without throwing errors @test
  • It handles values with partial JSON fragments @test

Stores values consistently

  • It stores string values in a way that they can be retrieved correctly @test
  • It stores object values with proper serialization @test

Implementation

@generates

API

/**
 * 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
};

Dependencies { .dependencies }

store { .dependency }

Provides cross-browser local storage support with automatic serialization and deserialization.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/store@2.0.x
tile.json