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

Legacy Storage Migration Tool

Build a storage migration utility that helps applications transition from store.js v1.x to v2.x by providing a compatibility layer that supports both API styles.

Requirements

Your utility should provide a storage interface that:

  1. Supports v1-style direct property access: Allow reading and writing values using direct property syntax (e.g., store.username = 'alice' and var name = store.username)

  2. Handles v1-style transact method: Implement a transaction method that accepts a key and a function. The function receives the current value and returns the new value. This should work for creating, updating, and removing values (return undefined to remove).

  3. Supports v1-style getAll method: Provide a method that returns all stored key-value pairs as a plain JavaScript object.

  4. Supports v1-style serialize and deserialize: Allow custom serialization and deserialization functions to be configured. These should be used for all storage operations.

  5. Maintains modern v2 API compatibility: Ensure that standard v2 methods (get, set, remove, clearAll) continue to work alongside the v1-style API.

Test Cases

  • Setting a value using property assignment (store.key = 'value') stores it correctly and can be retrieved using property access @test
  • Reading a non-existent property returns undefined @test
  • The transact method updates an existing value by passing it through a transformation function @test
  • The transact method creates a new value when the key doesn't exist and the function returns a value @test
  • The getAll method returns all stored key-value pairs as a plain object @test
  • Custom serialize and deserialize functions are used for storage operations @test

Implementation

@generates

API

/**
 * Creates a storage instance with v1 backwards compatibility
 * @returns {Object} Storage interface supporting both v1 and v2 APIs
 */
function createLegacyStorage() {
  // Implementation
}

module.exports = { createLegacyStorage };

Dependencies { .dependencies }

store { .dependency }

Provides cross-browser local storage with plugin support for backwards compatibility.

@satisfied-by

Version

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