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

Session Storage Manager

A utility that manages session-specific data with the ability to reset all stored information.

Capabilities

Initialize with default data

  • It initializes the storage with a set of default key-value pairs on first load @test

Store session data

  • It stores a user preference (like theme or language) in the session storage @test
  • It stores multiple configuration settings at once @test

Retrieve session data

  • It retrieves a stored value by its key @test
  • It returns undefined when retrieving a non-existent key @test

Clear all session data

  • It removes all stored data when the reset function is called @test
  • It confirms that no data remains after clearing all entries @test

Implementation

@generates

The implementation should provide a simple module that:

  • Exports functions for initializing, storing, retrieving, and clearing session data
  • Uses the storage library to persist data across page reloads (when using localStorage)
  • Provides a reset function that clears all stored entries

API

/**
 * Initializes the storage with default values if not already set.
 *
 * @param {Object} defaults - An object containing default key-value pairs
 */
function initialize(defaults) {
  // IMPLEMENTATION HERE
}

/**
 * Stores a value under a specific key.
 *
 * @param {string} key - The key to store the value under
 * @param {*} value - The value to store (will be automatically serialized)
 */
function setData(key, value) {
  // IMPLEMENTATION HERE
}

/**
 * Retrieves a value by its key.
 *
 * @param {string} key - The key to retrieve
 * @returns {*} The stored value, or undefined if not found
 */
function getData(key) {
  // IMPLEMENTATION HERE
}

/**
 * Clears all stored data from the storage.
 */
function resetAll() {
  // IMPLEMENTATION HERE
}

module.exports = {
  initialize,
  setData,
  getData,
  resetAll
};

Dependencies { .dependencies }

store { .dependency }

Provides cross-browser local storage support.

Package: store@2.0.12

Version

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