{"id":20494332,"url":"https://github.com/voltra/gdpr-guard-local","last_synced_at":"2026-02-28T06:31:21.203Z","repository":{"id":57245591,"uuid":"273723523","full_name":"Voltra/gdpr-guard-local","owner":"Voltra","description":"A simple local storage adapter for gdpr-guard","archived":false,"fork":false,"pushed_at":"2024-07-06T16:45:17.000Z","size":593,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T13:19:30.281Z","etag":null,"topics":["front-end","frontend","gdpr","gdpr-guard","hacktoberfest","javascript-library","localstorage","typescript-definitions","typescript-library"],"latest_commit_sha":null,"homepage":"https://voltra.github.io/gdpr-guard-local","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/Voltra.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":"2020-06-20T14:27:41.000Z","updated_at":"2024-07-06T16:44:23.000Z","dependencies_parsed_at":"2024-11-15T17:39:39.509Z","dependency_job_id":"76d45c37-6192-49b9-ae76-581fbd09a100","html_url":"https://github.com/Voltra/gdpr-guard-local","commit_stats":{"total_commits":29,"total_committers":2,"mean_commits":14.5,"dds":0.03448275862068961,"last_synced_commit":"efa5c47c17f7b773a6ff189e96ac69506fba38e3"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Voltra%2Fgdpr-guard-local","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Voltra%2Fgdpr-guard-local/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Voltra%2Fgdpr-guard-local/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Voltra%2Fgdpr-guard-local/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Voltra","download_url":"https://codeload.github.com/Voltra/gdpr-guard-local/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248750852,"owners_count":21155795,"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":["front-end","frontend","gdpr","gdpr-guard","hacktoberfest","javascript-library","localstorage","typescript-definitions","typescript-library"],"created_at":"2024-11-15T17:39:08.435Z","updated_at":"2026-02-28T06:31:21.171Z","avatar_url":"https://github.com/Voltra.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gdpr-guard-local\n\n\u003e A simple local storage adapter for gdpr-guard\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/Voltra/gdpr-guard-local/dev/gdpr-guard-local.png\" alt=\"Logo\" width=\"250\"/\u003e\u003c/center\u003e\n\nThis library predefines logic to store/save and restore [`gdpr-guard`](https://github.com/Voltra/gdpr-guard) state from localStorage.\n\nIf you need any help, you're more than welcome on my [official Discord server](https://discordapp.com/invite/JtWAjbw) dedicated to my open-source projects.\n\nYou can read the online [documentation](https://voltra.github.io/gdpr-guard-local/).\n\n## How to import\n\nThis library re-exports [what's exported by `gdpr-guard`](https://github.com/Voltra/gdpr-guard/blob/master/README.md#how-to-import).\n\n\n\n```javascript\nimport {\n    // everything from gdpr-guard\n    defaults,\n    LocalStorageSavior,\n} from \"gdpr-guard-local\"\n\n\n// In your browser\nconst {\n\t// everything from gdpr-guard\n\tdefaults,\n\tLocalStorageSavior,\n} = gdprGuardLocal;\n```\n\n## LocalStorageSavior\n\n`LocalStorageSavior` is a class that specializes the Savior API for local storage.\n\nIt is mainly for libraries developers or can be used as parameters for a library.\n\nTo construct one, simply pass a `LocalStorageConfig` object followed by a `LocalStoreFactory` (both are optional with default values):\n\n```typescript\ninterface LocalStorageConfig{\n    storeKey: string; // key of the serialized manager in local storage\n    versionKey: string; // key of the version of the serialized manager in local storage\n    version: string|number; // current version\n    comparator: (oldVersion, newVersion) =\u003e boolean; // if the versions are different\n    expiration: () =\u003e Date; // expiration date from current time\n}\n\ntype LocalStoreFactory = () =\u003e LocalStore;\n\ninterface LocalStore{\n    has(key: string): Promise\u003cboolean\u003e;\n    set(key: string, value: any, expiration: Date): Promise\u003cvoid\u003e;\n    remove(key: string): Promise\u003cvoid\u003e;\n    get(key: string): Promise\u003cany\u003e;\n    removeExpiredKeys(): Promise\u003cvoid\u003e;\n}\n\nconst savior = new LocalStorageSavior(myConfig, myStoreFactory);\n```\n\nTo help users and developers, we provide default values as well as ways to easily create new values for the parameters.\n\n## Defaults\n\n```javascript\nconst {\n    defaultStoreFactory, // the default argument of the savior constructor\n    expiration, // utility function\n    defaultConfig, // the default argument of the savior\n    makeConfig,\n} = defaults;\n```\n\nThe `makeConfig` function is a utility function that merges the user provided config object with the default config:\n\n```typescript\ndeclare const makeConfig: (config: Partial\u003cLocalStorageConfig\u003e = {}): LocalStorageConfig;\n```\n\nFor instance, you can customize the savior like this:\n\n```javascript\nconst savior = new LocalStorageSavior(\n    makeConfig({\n        version: \"v1.0.0\",\n        //storeKey will be gdpr\n        //versionKey will be gdpr__version\n    }),\n    defaultStoreFactory, // optional, that's already the default parameter\n);\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoltra%2Fgdpr-guard-local","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvoltra%2Fgdpr-guard-local","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoltra%2Fgdpr-guard-local/lists"}