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-5/

Browser Storage Utility

Build a browser storage utility that works across different browsers and environments, including older browsers and privacy modes where standard storage may not be available.

Requirements

Your utility should provide persistent key-value storage that:

  1. Works in all browser environments - including modern browsers, older browsers, and privacy/incognito modes where standard storage mechanisms may fail
  2. Automatically selects working storage - tries multiple storage mechanisms and uses the first one that works
  3. Provides consistent API - offers simple get/set operations regardless of the underlying storage mechanism
  4. Handles storage failures gracefully - doesn't crash when a storage mechanism is unavailable

Storage Priority

The utility should attempt to use storage mechanisms in this order:

  1. localStorage (primary)
  2. sessionStorage (secondary)
  3. In-memory storage (fallback)

Test Cases

  • Setting a string value and retrieving it returns the correct value @test
  • The utility correctly reports storage availability status @test
  • Multiple values can be stored and retrieved independently @test

Implementation

@generates

API

/**
 * Stores a value under the given key
 * @param {string} key - The storage key
 * @param {any} value - The value to store (will be serialized)
 */
export function set(key, value);

/**
 * Retrieves a value by key
 * @param {string} key - The storage key
 * @returns {any} The stored value, or undefined if not found
 */
export function get(key);

/**
 * Checks if persistent storage is available
 * @returns {boolean} true if persistent storage is working, false if using in-memory fallback
 */
export function isAvailable();

Dependencies { .dependencies }

store { .dependency }

Provides cross-browser local storage support.

Version

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