{"id":21693350,"url":"https://github.com/lullaby6/client-storage-handler","last_synced_at":"2025-03-20T13:57:12.036Z","repository":{"id":252408482,"uuid":"840334943","full_name":"lullaby6/client-storage-handler","owner":"lullaby6","description":"JavaScript Library - Methods for localStorage, sessionStorage and Cookies","archived":false,"fork":false,"pushed_at":"2024-08-26T19:20:18.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-25T13:25:07.824Z","etag":null,"topics":["java-script","javascript","js","js-lib","js-library"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lullaby6.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-09T13:25:30.000Z","updated_at":"2024-08-26T19:20:21.000Z","dependencies_parsed_at":"2024-08-26T21:45:34.950Z","dependency_job_id":"df2853cc-0d5a-468a-9cea-45a7ac7e4b70","html_url":"https://github.com/lullaby6/client-storage-handler","commit_stats":null,"previous_names":["lullaby6/client-storage-handler"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lullaby6%2Fclient-storage-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lullaby6%2Fclient-storage-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lullaby6%2Fclient-storage-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lullaby6%2Fclient-storage-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lullaby6","download_url":"https://codeload.github.com/lullaby6/client-storage-handler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244623528,"owners_count":20483167,"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":["java-script","javascript","js","js-lib","js-library"],"created_at":"2024-11-25T18:19:35.831Z","updated_at":"2025-03-20T13:57:12.005Z","avatar_url":"https://github.com/lullaby6.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Client Storage Handler (CSH)\n\nClient Storage Handler (CSH) is a lightweight JavaScript library that provides a simple and consistent interface for managing client-side storage, including localStorage, sessionStorage, and cookies.\n\n## Features\n\n- Easy-to-use methods for localStorage, sessionStorage, and cookies\n- Consistent API across storage types\n- Helper functions for common operations\n- Object storage support for localStorage and sessionStorage\n\n## Installation\n\n### CDN\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/gh/lullaby6/client-storage-handler/cdn.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\nAfter including the library, you can access its functionality through the csh object.\n\n```js\n// Local Storage\ncsh.local.set('key', 'value');\nconsole.log(csh.local.get('key')); // 'value'\n\n// Session Storage\ncsh.session.set('tempKey', 'tempValue');\nconsole.log(csh.session.get('tempKey')); // 'tempValue'\n\n// Cookies\ncsh.cookies.set('user', 'John');\nconsole.log(csh.cookies.get('user')); // 'John'\n```\n\n## API Reference\n\n### Local Storage (csh.local) and Session Storage (csh.session)\n\nBoth csh.local and csh.session share the same API:\n\n| Method | Description |\n|-----------------|----------------------------------------------------------------------------|\n| getAll() | Get all items in storage |\n| clear() | Clear all items from storage |\n| get(key) | Get an item by key (or all items if no key is provided) |\n| set(key, value) | Set an item |\n| remove(key) | Remove an item |\n| rename(key, newKey) | Rename an item |\n| has(key) | Check if an item exists |\n| isEmpty() | Check if storage is empty |\n| size() | Get the number of items in storage |\n| keys() | Get all keys in storage |\n| values() | Get all values in storage |\n| entries() | Get all key-value pairs in storage |\n| setObject(key, value) | Set a JSON object |\n| getObject(key) | Get a JSON object |\n\n### Cookies (csh.cookies)\n\n| Method | Description |\n|-----------------|----------------------------------------------------------------------------|\n| getAll() | Get all cookies |\n| clear() | Clear all cookies |\n| get(key) | GGet a cookie by key (or all cookies if no key is provided) |\n| set(key, value, days = null) | Set a cookie (no expiration by default) |\n| setExpiration(key, days = 1) | Set cookie days expiration |\n| remove(key) | Remove a cookie |\n| rename(key, newKey) | Rename a cookie |\n| has(key) | Check if a cookie exists |\n| isEmpty() | Check if there are no cookies |\n| size() | Get the number of cookies |\n| keys() | Get all cookie keys |\n| values() | Get all cookie values |\n| entries() | Get all cookie key-value pairs |\n\n## Examples\n\n### Local Storage\n\n```js\n// Set and get a value\ncsh.local.set('username', 'Alice');\nconsole.log(csh.local.get('username')); // 'Alice'\n\n// Store and retrieve an object\nconst user = { name: 'Bob', age: 30 };\ncsh.local.setObject('user', user);\nconst retrievedUser = csh.local.getObject('user');\nconsole.log(retrievedUser.name); // 'Bob'\n\n// Check if localStorage has an item\nconsole.log(csh.local.has('username')); // true\n\n// Get all keys\nconsole.log(csh.local.keys()); // ['username', 'user']\n\n// Clear all items\ncsh.local.clear();\n```\n\n### Session Storage\n\n```js\n// Set and get a value\ncsh.session.set('tempUsername', 'Charlie');\nconsole.log(csh.session.get('tempUsername')); // 'Charlie'\n\n// Store and retrieve an object\nconst tempUser = { name: 'David', age: 25 };\ncsh.session.setObject('tempUser', tempUser);\nconst retrievedTempUser = csh.session.getObject('tempUser');\nconsole.log(retrievedTempUser.name); // 'David'\n\n// Check if sessionStorage has an item\nconsole.log(csh.session.has('tempUsername')); // true\n\n// Get all keys\nconsole.log(csh.session.keys()); // ['tempUsername', 'tempUser']\n\n// Clear all items\ncsh.session.clear();\n```\n\n### Cookies\n\n```js\n// Set and get a cookie that expires in 3 days\ncsh.cookies.set('session', 'abc123', 3);\nconsole.log(csh.cookies.get('session')); // 'abc123'\n\n// Check if a cookie exists\nconsole.log(csh.cookies.has('session')); // true\n\n// Get all cookies\nconsole.log(csh.cookies.getAll());\n\n// Remove a cookie\ncsh.cookies.remove('session');\n\n// Clear all cookies\ncsh.cookies.clear();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flullaby6%2Fclient-storage-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flullaby6%2Fclient-storage-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flullaby6%2Fclient-storage-handler/lists"}