{"id":16973794,"url":"https://github.com/smartacephale/lskdb","last_synced_at":"2026-04-24T16:04:46.243Z","repository":{"id":253691735,"uuid":"844246122","full_name":"smartacephale/lskdb","owner":"smartacephale","description":"Local Storage Key DB","archived":false,"fork":false,"pushed_at":"2024-09-30T03:42:17.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T20:33:05.850Z","etag":null,"topics":["cdn","db","keydb","localstorage","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/lskdb","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smartacephale.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-18T20:18:56.000Z","updated_at":"2024-09-30T03:42:20.000Z","dependencies_parsed_at":"2024-08-18T20:55:34.431Z","dependency_job_id":null,"html_url":"https://github.com/smartacephale/lskdb","commit_stats":null,"previous_names":["smartacephale/lskdb"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartacephale%2Flskdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartacephale%2Flskdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartacephale%2Flskdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartacephale%2Flskdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smartacephale","download_url":"https://codeload.github.com/smartacephale/lskdb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501902,"owners_count":21114681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cdn","db","keydb","localstorage","typescript"],"created_at":"2024-10-14T01:03:36.301Z","updated_at":"2026-04-24T16:04:46.143Z","avatar_url":"https://github.com/smartacephale.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LSKDB\n## Local Storage Key DB\n![](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQubeF9ytu4axK5_hfm30kFuwqvQjaigCw-tQ\u0026s)\n \nThis library provides a simple, type-safe API for managing keys in localStorage with a defined prefix.\n\n### Installation\n\n```bash\nnpm i lskdb\n```\n\n```\n\u003cscript src=\"https://unpkg.com/lskdb@latest/dist/lskdb.umd.js\"\u003e\u003c/script\u003e\n...\nconst { LSKDB } = window.lskdb;\n```\n\n### Usage\n\nImport the `LSKDB` class and create an instance:\n\n```typescript\nimport { LSKDB } from 'lskdb';\n\nconst db = new LSKDB();\n```\n\n**Available methods:**\n\n* **getAllKeys()**: Returns an array of all keys starting with the configured prefix, without the prefix itself.\n* **getKeys(n: number, remove?: boolean)**: Gets a limited number (`n`) of keys with the prefix and optionally removes them from localStorage. Returns an array of keys without the prefix.\n* **hasKey(key: string)**: Checks if a specific key with the prefix exists.\n* **removeKey(key: string | number)**: Removes a specific key with the prefix from localStorage.\n* **setKey(key: string | number)**: Sets an key with the prefix in localStorage.\n* **isLocked()**: Checks if the database is locked based on a lock timeout.\n* **lock(value: boolean)**: Locks or unlocks the database.\n\n**Example:**\n\n```typescript\ndb.setKey('user-data');\n\nif (!db.hasKey('settings')) {\n  db.setKey('settings');\n}\n\nconst recentKeys = db.getKeys(5); // Get 5 recent keys without removing\nconsole.log(recentKeys);\n\ndb.removeKey('user-data');\n\nif (!db.isLocked()) {\n  // Perform actions while the database is unlocked\n  db.lock(true); // Lock after use\n}\n```\n\n### Configuration (Optional)\n\nYou can configure the prefix used for keys and the lock key name during initialization:\n\n```typescript\nconst db = new LSKDB('my-app-', 'lock');\n```\n\n**Note:** Lock functionality is based on a simple time-based check. Consider using a more robust locking mechanism for critical applications.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartacephale%2Flskdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartacephale%2Flskdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartacephale%2Flskdb/lists"}