{"id":17168924,"url":"https://github.com/ciriousjoker/ts-localstorage","last_synced_at":"2025-08-28T02:40:22.572Z","repository":{"id":57380871,"uuid":"311950666","full_name":"ciriousjoker/ts-localstorage","owner":"ciriousjoker","description":"npm package for typed localstorage","archived":false,"fork":false,"pushed_at":"2023-12-20T22:53:46.000Z","size":426,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-30T09:18:04.965Z","etag":null,"topics":["local","localstorage","localstorage-wrapper","storage","ts","type-safety","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/ts-localstorage","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/ciriousjoker.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2020-11-11T11:29:34.000Z","updated_at":"2024-06-07T15:26:06.000Z","dependencies_parsed_at":"2025-04-13T15:56:36.957Z","dependency_job_id":"c6910ed3-99de-4ce4-9ff7-5f9a58638746","html_url":"https://github.com/ciriousjoker/ts-localstorage","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ciriousjoker/ts-localstorage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ciriousjoker%2Fts-localstorage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ciriousjoker%2Fts-localstorage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ciriousjoker%2Fts-localstorage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ciriousjoker%2Fts-localstorage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ciriousjoker","download_url":"https://codeload.github.com/ciriousjoker/ts-localstorage/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ciriousjoker%2Fts-localstorage/sbom","scorecard":{"id":283218,"data":{"date":"2025-08-11","repo":{"name":"github.com/ciriousjoker/ts-localstorage","commit":"199ba35fe934c80d2700467ccf350667e2015a78"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.1,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/16 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql.yml:29","Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql.yml:28","Warn: no topLevel permission defined: .github/workflows/codeql.yml:1","Warn: no topLevel permission defined: .github/workflows/npm-publish.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":2,"reason":"dependency not pinned by hash detected -- score normalized to 2","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/ciriousjoker/ts-localstorage/codeql.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/ciriousjoker/ts-localstorage/codeql.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:59: update your workflow using https://app.stepsecurity.io/secureworkflow/ciriousjoker/ts-localstorage/codeql.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:72: update your workflow using https://app.stepsecurity.io/secureworkflow/ciriousjoker/ts-localstorage/codeql.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/ciriousjoker/ts-localstorage/npm-publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/ciriousjoker/ts-localstorage/npm-publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/ciriousjoker/ts-localstorage/npm-publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/ciriousjoker/ts-localstorage/npm-publish.yml/main?enable=pin","Info:   0 out of   8 GitHub-owned GitHubAction dependencies pinned","Info:   2 out of   2 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":7,"reason":"SAST tool detected but not run on all commits","details":["Info: SAST configuration detected: CodeQL","Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"13 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T16:29:43.190Z","repository_id":57380871,"created_at":"2025-08-17T16:29:43.191Z","updated_at":"2025-08-17T16:29:43.191Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272424127,"owners_count":24932893,"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","status":"online","status_checked_at":"2025-08-28T02:00:10.768Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["local","localstorage","localstorage-wrapper","storage","ts","type-safety","typescript"],"created_at":"2024-10-14T23:13:24.539Z","updated_at":"2025-08-28T02:40:22.535Z","avatar_url":"https://github.com/ciriousjoker.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TS-LocalStorage \u003csub\u003e[(changelog)](CHANGELOG.md)\u003c/sub\u003e\n\n[![npm](https://img.shields.io/npm/l/ts-localstorage.svg)](https://github.com/ciriousjoker/ts-localstorage/blob/main/LICENSE)\n![npm](https://ciriousjoker.github.io/ts-localstorage/coverage/badge.svg)\n\nA drop in replacement for `localStorage` to add type safety and improved serialization.\n\nJust replace `localStorage` with `LocalStorage` and create your keys like this:\n\n```typescript\n// The sample value is only required to make serialization work properly.\n// It is now used for anything else unless you set `hasDefaultValue: true`\nconst key = new LocalKey(\"mykey\", \"\");\n```\n\n**This package does not make sure your keys are unique.**\n\n## Usage\n\n```typescript\nconst key = \"mykey\";\nconst value = localStorage.getItem(key);\nlocalStorage.setItem(key, \"newvalue\");\n```\n\ncan be refactored into:\n\n```typescript\nimport { LocalStorage } from \"ts-localstorage\";\n\nconst key = new LocalKey(\"mykey\", \"\");\nconst value = LocalStorage.getItem(key); // =\u003e string\nLocalStorage.setItem(key, \"newvalue\");\n```\n\n### Other built-in types\n\nThis also works with a couple other types out of the box, most notably `Date`, `Map`.\nCheck the [supported types](#supported-types) for a complete list.\n\n```typescript\nconst key = new LocalKey(\"mykey\", new Date());\nconst value = LocalStorage.getItem(key); // =\u003e Date\n\nLocalStorage.setItem(key, \"newvalue\"); // error, \"newvalue\" isn't a Date\nLocalStorage.setItem(key, new Date());\n```\n\n### Simple objects\n\nIf you have a simple interface that you want to store and retrieve, declare your key like this:\n\n```typescript\nconst key = new LocalKey\u003cMyInterface\u003e(\"mykey\", null);\nconst value = LocalStorage.getItem(key); // =\u003e MyInterface\nLocalStorage.setItem(key, { ... } as MyInterface);\n```\n\nThis uses `JSON.stringify()` and `JSON.parse()` under the hood, with all its implications regarding number/Date/Map/etc. conversion.\n\n### Custom Converters\n\nYou can use any object instance via custom converters:\n\n```typescript\nconst key = new LocalKey(\"mykey\", new MyClass(), {\n  toStorage: (value: MyClass): string =\u003e {\n    // return serialized value\n  },\n  fromStorage: (value: string): MyClass =\u003e {\n    // parse value into a MyClass instance\n  },\n});\n```\n\n### Default values\n\nThe first call to `getItem()` will usually return null because it doesn't have a value yet:\n\n```typescript\nconst key = new LocalKey(\"mykey\", false);\nconst value = LocalStorage.getItem(key); // =\u003e null\nLocalStorage.setItem(key, true);\nconst value = LocalStorage.getItem(key); // =\u003e true\n```\n\nYou can override this behavior like this:\n\n```typescript\nconst key = new LocalKey(\"mykey\", false, {\n  hasDefaultValue: true,\n});\nconst value = LocalStorage.getItem(key); // =\u003e false\nLocalStorage.setItem(key, true);\nconst value = LocalStorage.getItem(key); // =\u003e true\n```\n\n### Passing null and undefined to setItem()\n\nIn the native `localStorage`, passing `null` or `undefined` will store it as `\"null\"` or `\"undefined\"`. In my experience, this easily leads to issues that are hard to debug. Therefore, if you pass `null` or `undefined` to `LocalStorage.setItem()`, it will internally call `LocalStorage.removeItem()` instead.\n\n```typescript\nconst key = new LocalKey\u003cstring | null | undefined\u003e(\"mykey\", \"\");\n\nLocalStorage.setItem(key, \"test\");\nLocalStorage.setItem(key, null);\nLocalStorage.getItem(key); // =\u003e null\n\nLocalStorage.setItem(key, \"test\");\nLocalStorage.setItem(key, undefined);\nLocalStorage.getItem(key); // =\u003e null (in order to stay as close to localStorage as possible)\n```\n\n## Supported types\n\n- `boolean`\n- `Boolean` (will be returned as Boolean)\n- `number`\n- `Number` (will be returned as Number)\n- `string`\n- `String` (will be returned as String)\n- `Date`\n- `Map`\n- Basic object literals (converted automatically via `JSON.stringify()` \u0026 `JSON.parse()`)\n- Custom class instances (requires a [custom converter](#custom-converters))\n\n---\n\nCheck out [the tests](src/index.test.ts) for info on edge cases like functions and classes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fciriousjoker%2Fts-localstorage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fciriousjoker%2Fts-localstorage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fciriousjoker%2Fts-localstorage/lists"}