{"id":21961877,"url":"https://github.com/trapcodeio/browser-storage","last_synced_at":"2025-07-22T12:32:21.330Z","repository":{"id":40407676,"uuid":"237259234","full_name":"trapcodeio/browser-storage","owner":"trapcodeio","description":"Support all browser storage using one Api","archived":false,"fork":false,"pushed_at":"2023-10-08T05:05:43.000Z","size":81,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-29T08:42:14.739Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/trapcodeio.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}},"created_at":"2020-01-30T16:51:38.000Z","updated_at":"2023-01-14T13:05:00.000Z","dependencies_parsed_at":"2022-08-09T19:31:11.840Z","dependency_job_id":null,"html_url":"https://github.com/trapcodeio/browser-storage","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fbrowser-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fbrowser-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fbrowser-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fbrowser-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trapcodeio","download_url":"https://codeload.github.com/trapcodeio/browser-storage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227096597,"owners_count":17730377,"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":[],"created_at":"2024-11-29T10:19:29.658Z","updated_at":"2024-11-29T10:19:30.489Z","avatar_url":"https://github.com/trapcodeio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Browser Storage\n\nA simple package for handling `localstorage` \u0026 `sessionStorage`.\n\n### Installation\n\n```shell\nnpm i @trapcode/browser-storage\n# OR\nyarn add @trapcode/browser-storage\n```\n\n### Problem\n\nThe native `localstorage` and `sessionStorage` stores every data as `string` by default, This makes **setting** and **\ngetting** other types difficult. For example:\n\n```javascript\nlocalStorage.setItem(\"isVerified\", true)\nlocalStorage.setItem(\"age\", 18)\nlocalStorage.setItem(\"object\", {foo: \"bar\"})\n\n// All will return as string regardless\nlocalStorage.getItem(\"isVerified\") // \"true\" as string\nlocalStorage.getItem(\"age\") // \"18\" as string\nlocalStorage.getItem(\"object\") // \"[Object Object]\" as string\n```\n\nFrom the above example, you will have to do some conversions to get the original data type stored.\n\n### Solution\n\nThe way the browser stores data cannot be modified but how you **set \u0026 get** data can make a huge difference. This\npackage includes **semantic helper methods** that adds some sort of **type certainty**.\n\nFor example:\n\n```javascript\n// Import and initialize store.\nimport BrowserStorage from '@trapcode/browser-storage';\n\nconst localStore = BrowserStorage.getLocalStore();\n\nlocalStore.setBoolean(\"isVerified\", true)\nlocalStore.setNumber(\"age\", 18)\nlocalStore.setObject(\"object\", {foo: \"bar\"})\n\n// You get the exact types.\nlocalStore.getBoolean(\"isVerified\") // true as boolean\nlocalStore.getNumber(\"age\") // 18 as number\nlocalStore.getObject(\"object\", {foo: \"bar\"}) // {foo: \"bar\"} as object\n```\n\n### Base64Encryption\n\nif you don't want the values in your store to be humanly readable, you can enable `Base64Encryption`. Your data will\nbe **Encoded** on `set` actions and **Decoded** automatically on `get` actions\n\n```javascript\nimport BrowserStorage from '@trapcode/browser-storage';\n\n// Initialize\nconst localStore = BrowserStorage.getLocalStore();\n\n// Enable Encryption\nlocalStore.enableBase64Encryption()\n\n// Also accepts true/false value as argument\nlocalStore.enableBase64Encryption(true / false)\n\n// For example\nlocalStore.enableBase64Encryption(process.env.NODE_ENV === \"production\")\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrapcodeio%2Fbrowser-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrapcodeio%2Fbrowser-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrapcodeio%2Fbrowser-storage/lists"}