{"library":"lockr","title":"Lockr: LocalStorage Wrapper","description":"Lockr is an extremely lightweight JavaScript library (<2KB minified) designed to simplify interactions with the browser's `localStorage` API. It provides a Redis-like API for storing various data types, including strings, numbers, objects, and arrays, and offers set-like operations (e.g., `sadd`, `smembers`, `sismember`, `srem`). It is currently in a beta phase, with version 0.9.0-beta.2, indicating ongoing development. While no explicit release cadence is stated, the active development and beta tag suggest regular updates towards a stable release. Its primary differentiator is its automatic object serialization/deserialization and its distinct Redis-inspired API for managing collections, moving beyond the simple key-value string storage of native `localStorage` and offering a more feature-rich experience.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install lockr"],"cli":null},"imports":["import Lockr from 'lockr'","const Lockr = require('lockr')","import * as Lockr from 'lockr'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import Lockr from 'lockr';\n\n// Set a prefix for all keys (optional, but good practice)\nLockr.prefix = 'my_app_data_';\n\n// Store various data types. Lockr automatically serializes objects and arrays.\nLockr.set('username', 'Alice Smith');\nLockr.set('userId', 42);\nLockr.set('settings', { theme: 'dark', notifications: true });\nLockr.set('favoriteFruits', ['apple', 'banana', 'cherry']);\n\n// Retrieve values. Lockr automatically deserializes them.\nconsole.log('Username:', Lockr.get('username'));\n// Expected: Username: Alice Smith\n\nconsole.log('Settings:', Lockr.get('settings'));\n// Expected: Settings: { theme: 'dark', notifications: true }\n\n// Use Redis-like set operations (sadd, smembers)\nLockr.sadd('uniqueTags', 'javascript');\nLockr.sadd('uniqueTags', 'typescript');\nLockr.sadd('uniqueTags', 'javascript'); // Adding again has no effect\n\nconsole.log('Unique Tags:', Lockr.smembers('uniqueTags'));\n// Expected: Unique Tags: [ 'javascript', 'typescript' ]\n\n// Remove a key\nLockr.rm('username');\nconsole.log('Username after removal:', Lockr.get('username', 'Guest'));\n// Expected: Username after removal: Guest (demonstrating default value)\n\n// Get all values (only prefixed ones if prefix is set)\nconsole.log('All stored values:', Lockr.getAll());","lang":"typescript","description":"Demonstrates setting a key prefix, storing various data types (strings, numbers, objects, arrays), retrieving them, performing set-like operations, and removing keys.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}