{"id":20744595,"url":"https://github.com/npezza93/pref","last_synced_at":"2026-07-21T21:32:13.527Z","repository":{"id":57329711,"uuid":"149526331","full_name":"npezza93/pref","owner":"npezza93","description":"Add preferences to your electron app","archived":false,"fork":false,"pushed_at":"2021-08-31T03:59:32.000Z","size":65,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-08T14:44:52.419Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/npezza93.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}},"created_at":"2018-09-20T00:02:18.000Z","updated_at":"2021-08-31T03:59:24.000Z","dependencies_parsed_at":"2022-09-10T13:51:27.372Z","dependency_job_id":null,"html_url":"https://github.com/npezza93/pref","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/npezza93/pref","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npezza93%2Fpref","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npezza93%2Fpref/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npezza93%2Fpref/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npezza93%2Fpref/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/npezza93","download_url":"https://codeload.github.com/npezza93/pref/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npezza93%2Fpref/sbom","scorecard":{"id":696154,"data":{"date":"2025-08-11","repo":{"name":"github.com/npezza93/pref","commit":"9189bff4953a41ec196a6885dc5909c7a19aec59"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"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":"Code-Review","score":0,"reason":"Found 0/25 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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"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":-1,"reason":"No tokens found","details":null,"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":"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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"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":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"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 'master'"],"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":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 6 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"}}]},"last_synced_at":"2025-08-22T03:45:55.005Z","repository_id":57329711,"created_at":"2025-08-22T03:45:55.005Z","updated_at":"2025-08-22T03:45:55.005Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35738159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-21T02:00:06.728Z","response_time":109,"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":[],"created_at":"2024-11-17T07:16:16.175Z","updated_at":"2026-07-21T21:32:13.511Z","avatar_url":"https://github.com/npezza93.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pref [![Build Status: Linux and macOS](https://travis-ci.org/npezza93/pref.svg?branch=master)](https://travis-ci.org/npezza93/pref)\n\n\u003e Simple preference handling for your electron application\n\nThis is heavily inspired by and an extension of [@sindresorhus](https://github.com/sindresorhus)'s [conf](https://github.com/sindresorhus/conf) and [electron-store](https://github.com/sindresorhus/electron-store) projects. Shout out to him for creating these spectacular packages.\n\n## Install\n\n```bash\n❯ yarn add pref\n```\n\n## Usage\n\n```js\nconst Pref = require('pref');\nconst preferences = new Pref();\n\npreferences.set('spaceInvader', '👾');\nconsole.log(preferences.get('spaceInvader'));\n//=\u003e '👾'\n\n// Use dot-notation to access nested properties\npreferences.set('foo.bar', true);\nconsole.log(preferences.get('foo'));\n//=\u003e {bar: true}\n\npreferences.delete('spaceInvader');\nconsole.log(preferences.get('spaceInvader'));\n//=\u003e undefined\n```\n\n## API\n\nChanges are written to disk atomically, so if the process crashes during a write, it will not corrupt the existing config.\n\n### Pref([options])\n\nReturns a new instance.\n\n### options\n\n#### defaults\n\nType: `Object`\n\nDefault config.\n\n#### configName\n\nType: `string`\u003cbr\u003e\nDefault: `config`\n\nName of the config file (without extension).\n\nUseful if you need multiple config files for your app or module. For example,\ndifferent config files between two major versions.\n\n#### projectName\n\nType: `string`\u003cbr\u003e\nDefault: The `name` field in the package.json closest to where `pref` is imported.\n\nYou only need to specify this if you don't have a package.json file in your\nproject.\n\n#### projectVersion\n\nType: `string`\u003cbr\u003e\nDefault: The `version` field in the package.json closest to where `pref` is imported.\n\nYou only need to specify this if you don't have a package.json file in your\nproject and if you are using migrations.\n\n#### cwd\n\nType: `string`\u003cbr\u003e\nDefault: System default [user config directory](https://github.com/sindresorhus/env-paths#pathsconfig)\n\n**You most likely don't need this. Please don't use it unless you really have to.**\n\nOverrides `projectName`.\n\nThe only use-case I can think of is having the config located in the app\ndirectory or on some external storage.\n\n#### fileExtension\n\ntype: `string`\u003cbr\u003e\nDefault: `json`\n\nExtension of the config file.\n\nYou would usually not need this, but could be useful if you want to interact\nwith a file with a custom file extension that can be associated with your app.\nThese might be simple save/export/preference files that are intended to be\nshareable or saved outside of the app.\n\n#### schema\n\ntype: `object`\u003cbr\u003e\nDefault: `undefined`\n\nJSON schema definition of store.\n\nYou can pass in a valid JSON schema and use it to coerce and validate your\nstore. By default if a schema is passed in, it will coerce and add the defaults\nlisted in the schema and coerce the values when you get them.\n\n#### watch\n\ntype: `boolean`\u003cbr\u003e\nDefault: `true`\n\nSets a file watcher.\n\nThis is useful if you have more than one window reading the preferences. If one\nwindow changes a preference, this allows it to get propagated to all instances\nof Pref. If only ever have one instance on Pref in your app you can turn this\noff.\n\n#### migrations\n\ntype: `object`\u003cbr\u003e\nDefault: `undefined`\n\nMigrations to be run between versions.\n\nUseful for transitioning preference changes between application versions. Ex:\n```js\n// version is set to 0.0.1, the current app version is 2.0.8, 'old' key is set to 1\nconst store = new Store({\n  migrations: {\n    '0.0.0': store =\u003e {\n      store.set('bad key', 2);\n    },\n    '1.0.0': store =\u003e {\n      const old = store.get('old');\n      store.set('new', old);\n      store.delete('old');\n    },\n    '1.0.2': store =\u003e {\n      store.set('a new key', 't');\n    }\n  }\n})\nstore.store\n=\u003e { version: '2.0.8', new: 1, 'a new key': 't' }\n```\n\n\n### Instance\n\nYou can use [dot-notation](https://github.com/sindresorhus/dot-prop) in a `key` to access nested properties.\n\nThe instance is [`iterable`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Iteration_protocols) so you can use it directly in a [`for…of`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/for...of) loop.\n\n#### .set(key, value)\n\nSet an item.\n\nThe `value` must be JSON serializable.\n\n#### .set(object)\n\nSet multiple items at once.\n\n#### .get(key, [defaultValue])\n\nGet an item or `defaultValue` if the item does not exist.\n\n#### .has(key)\n\nCheck if an item exists.\n\n#### .delete(key)\n\nDelete an item.\n\n#### .clear()\n\nDelete all items.\n\n#### .onDidChange(key, callback)\n\n`callback`: `(newValue, oldValue) =\u003e {}`\n\nWatches the given `key`, calling `callback` on any changes. When a key is first\nset `oldValue` will be `undefined`, and when a key is deleted `newValue` will be\n`undefined`.\n\n#### .size\n\nGet the item count.\n\n#### .store\n\nGet all the config as an object or replace the current config with an object:\n\n```js\npref.store = {\n  hello: 'world'\n};\n```\n\n#### .path\n\nGet the path to the config file.\n\n\n#### .isValid()\n\nValidates the store against the passed in JSON schema. Returns a boolean.\n\n\n## License\n\nMIT © [Nick Pezza](https://pezza.co)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpezza93%2Fpref","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpezza93%2Fpref","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpezza93%2Fpref/lists"}