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

User Preferences Manager

Build a user preferences manager that retrieves and manages application settings using persistent storage.

Requirements

Create a module that retrieves user preference values from storage with appropriate fallback defaults when preferences haven't been set yet.

Your implementation should:

  1. Retrieve the user's theme preference (key: theme), defaulting to "light" if not set
  2. Retrieve the user's language preference (key: language), defaulting to "en" if not set
  3. Retrieve the user's notification setting (key: notifications), defaulting to true if not set
  4. Retrieve a complex preference object for dashboard layout (key: dashboardLayout), defaulting to { columns: 2, widgets: [] } if not set

All preferences should be retrieved from persistent storage and return the appropriate default value when the preference hasn't been saved.

Implementation

@generates

API

/**
 * Gets the user's theme preference
 * @returns {string} The theme preference or "light" if not set
 */
function getTheme() {
  // Implementation here
}

/**
 * Gets the user's language preference
 * @returns {string} The language preference or "en" if not set
 */
function getLanguage() {
  // Implementation here
}

/**
 * Gets the user's notification setting
 * @returns {boolean} The notification setting or true if not set
 */
function getNotifications() {
  // Implementation here
}

/**
 * Gets the user's dashboard layout configuration
 * @returns {object} The dashboard layout or { columns: 2, widgets: [] } if not set
 */
function getDashboardLayout() {
  // Implementation here
}

module.exports = {
  getTheme,
  getLanguage,
  getNotifications,
  getDashboardLayout
};

Test Cases

  • When theme is not set, getTheme() returns "light" @test
  • When language is not set, getLanguage() returns "en" @test
  • When notifications is not set, getNotifications() returns true @test
  • When dashboardLayout is not set, getDashboardLayout() returns { columns: 2, widgets: [] } @test

Dependencies { .dependencies }

store { .dependency }

Provides persistent client-side storage functionality.

@satisfied-by

Version

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