{"id":22645377,"url":"https://github.com/heliomarpm/keyvalues-storage","last_synced_at":"2025-04-12T00:33:50.863Z","repository":{"id":158508633,"uuid":"628310401","full_name":"heliomarpm/keyvalues-storage","owner":"heliomarpm","description":"A simple and robust KeyValues Storage's library","archived":false,"fork":false,"pushed_at":"2024-08-18T21:35:18.000Z","size":344,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T20:15:43.720Z","etag":null,"topics":["app-library","config","data","db","json","json-db","keyvalues","localdb","settings","storage","store"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@heliomarpm/kvs","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/heliomarpm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"docs/CODE_OF_CONDUCT.md","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},"funding":{"github":"heliomarpm","ko_fi":"heliomarpm","liberapay":"heliomarpm","custom":["https://bit.ly/paypal-sponsor-heliomarpm","https://www.paypal.com/donate?business=KBVHLR7Z9V7B2\u0026no_recurring=0\u0026currency_code=BRL","https://www.pixme.bio/heliomarpm"]}},"created_at":"2023-04-15T14:52:45.000Z","updated_at":"2024-08-18T21:35:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"fc302d93-2532-47fd-a2f0-68005661a284","html_url":"https://github.com/heliomarpm/keyvalues-storage","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heliomarpm%2Fkeyvalues-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heliomarpm%2Fkeyvalues-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heliomarpm%2Fkeyvalues-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heliomarpm%2Fkeyvalues-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heliomarpm","download_url":"https://codeload.github.com/heliomarpm/keyvalues-storage/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501696,"owners_count":21114676,"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":["app-library","config","data","db","json","json-db","keyvalues","localdb","settings","storage","store"],"created_at":"2024-12-09T06:05:18.938Z","updated_at":"2025-04-12T00:33:50.840Z","avatar_url":"https://github.com/heliomarpm.png","language":"TypeScript","funding_links":["https://github.com/sponsors/heliomarpm","https://ko-fi.com/heliomarpm","https://liberapay.com/heliomarpm","https://bit.ly/paypal-sponsor-heliomarpm","https://www.paypal.com/donate?business=KBVHLR7Z9V7B2\u0026no_recurring=0\u0026currency_code=BRL","https://www.pixme.bio/heliomarpm"],"categories":[],"sub_categories":[],"readme":"\u003cdiv id=\"top\" align=\"center\" style=\"text-align:center;\"\u003e\n\u003ch1\u003e\n  \u003cbr\u003e🎲 KeyValues Storage\n\n  [![DeepScan grade][url-deepscan-badge]][url-deepscan]\n  [![CodeFactor][url-codefactor-badge]][url-codefactor] \n  ![CodeQL][url-codeql]\u003c!-- ![Publish][url-publish] --\u003e [![NPM version][url-npm-badge]][url-npm]\n  [![Downloads][url-downloads-badge]][url-downloads]\n  \u003ca href=\"https://navto.me/heliomarpm\" target=\"_blank\"\u003e\u003cimg src=\"https://navto.me/assets/navigatetome-brand.png\" width=\"32\"/\u003e\u003c/a\u003e\n\n  ![lodash](https://img.shields.io/github/package-json/dependency-version/heliomarpm/keyvalues-storage/lodash)\n  ![write-file-atomic](https://img.shields.io/github/package-json/dependency-version/heliomarpm/keyvalues-storage/write-file-atomic)\n  \u003c!-- ![jest](https://img.shields.io/github/package-json/dependency-version/heliomarpm/keyvalues-storage/dev/jest) --\u003e\n\u003c/h1\u003e\n\n\u003cp\u003e\n  \u003c!-- PixMe --\u003e\n  \u003ca href=\"https://www.pixme.bio/heliomarpm\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n    \u003cimg alt=\"pixme url\" src=\"https://img.shields.io/badge/donate%20on-pixme-1C1E26?style=for-the-badge\u0026labelColor=1C1E26\u0026color=28f4f4\"/\u003e\n  \u003c/a\u003e\n  \u003c!-- PayPal --\u003e\n  \u003ca href=\"https://bit.ly/paypal-sponsor-heliomarpm\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n    \u003cimg alt=\"paypal url\" src=\"https://img.shields.io/badge/paypal-1C1E26?style=for-the-badge\u0026labelColor=1C1E26\u0026color=0475fe\"/\u003e\n  \u003c/a\u003e\n  \u003c!-- Ko-fi --\u003e\n  \u003ca href=\"https://ko-fi.com/heliomarpm\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n    \u003cimg alt=\"kofi url\" src=\"https://img.shields.io/badge/kofi-1C1E26?style=for-the-badge\u0026labelColor=1C1E26\u0026color=ff5f5f\"/\u003e\n  \u003c/a\u003e\n  \u003c!-- LiberaPay --\u003e  \n  \u003ca href=\"https://liberapay.com/heliomarpm\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n     \u003cimg alt=\"liberapay url\" src=\"https://img.shields.io/badge/liberapay-1C1E26?style=for-the-badge\u0026labelColor=1C1E26\u0026color=f6c915\"/\u003e\n  \u003c/a\u003e\n  \u003c!-- Version --\u003e\n  \u003ca href=\"https://github.com/heliomarpm/keyvalues-storage/releases\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n     \u003cimg alt=\"releases url\" src=\"https://img.shields.io/github/v/release/heliomarpm/keyvalues-storage?style=for-the-badge\u0026labelColor=1C1E26\u0026color=2ea043\"/\u003e\n  \u003c/a\u003e  \n  \u003c!-- License --\u003e\n  \u003ca href=\"https://github.com/heliomarpm/keyvalues-storage/blob/main/LICENSE\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n    \u003cimg alt=\"license url\" src=\"https://img.shields.io/badge/license%20-MIT-1C1E26?style=for-the-badge\u0026labelColor=1C1E26\u0026color=61ffca\"/\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003c/div\u003e\n\n## Summary\nThe `KeyValues Storage` library is a utility for managing key-value pairs and storing them in a JSON file. It provides methods for setting, getting, checking existence, and removing key-value pairs. This document provides an overview of the library and its usage.\n\n## Installation\n\nYou can install the library using `npm` or `yarn`:\n\n```bash\nnpm i @heliomarpm/kvs\n# or \nyarn add @heliomarpm/kvs\n```\n\n## Example Usage\n\n```javascript\n// Create a new instance of KeyValues with or or without custom options\n\n/**\n * Default Options\n * \n * {\n *   atomicSave: true,\n *   fileName: 'keyvalues.json',\n *   prettify: false,\n *   numSpaces: 2,\n * }\n */\nconst kvs = new KeyValues()\n-- or --\nconst kvs = new KeyValues({\n  fileName: 'config.json',\n  prettify: true\n});\n\nconst color =\n{\n    \"name\": \"cerulean\",\n    \"code\": {\n        \"rgb\": [0, 179, 230],\n        \"hex\": \"#003BE6\"\n    }\n}\n\n// Set a key-values\nkvs.setSync('color', color);\n\nkvs.getSync('color.name')\n// =\u003e 'cerulean'\n\nkvs.getSync('color.code.hex')\n// =\u003e \"#003BE6\"\n\nkvs.getSync(['color', 'code'])\n// =\u003e { \"hex\": \"#003BE6\", \"rgb\": [0, 179, 230] }\n\nkvs.getSync(['color', 'hue'])\n// =\u003e undefined\n\n// Set a key-value pair\nawait kvs.set('color.name', 'sapphire');\n\n// Get the value at a specific key path\nconst value = await kvs.get('color.name');\n// =\u003e 'sapphire'\n\n// Check if a key path exists\nconst exists = await kvs.has('color.name');\n\n// Remove a key-value pair\nawait kvs.unset('color.name');\n\nkvs.getSync(); \n// =\u003e { \"code\": { \"rgb\": [0, 179, 230], \"hex\": \"#003BE6\" } }\n```\n\n## Code Analysis\n### Main functionalities\n- Manage key-value pairs and store them in a JSON file\n- Create one or more instances for different JSON files\n- Set and get values at specific key paths\n- Check if a key path exists\n- Remove key-value pairs\n___\n### Methods\n- `constructor(options?: Partial\u003cOptions\u003e)`: Initializes a new instance of the `KeyValues` class with optional custom options.\n- `file(): string`: Returns the path to the JSON file.\n- `reset(): void`: Resets the configuration of the `KeyValues` instance to default options.\n- `has(keyPath: KeyPath): Promise\u003cboolean\u003e`: Checks if a key path exists asynchronously.\n- `hasSync(keyPath: KeyPath): boolean`: Checks if a key path exists synchronously.\n- `get\u003cT extends valueTypes\u003e(keyPath?: KeyPath): Promise\u003cT\u003e`: Gets the value at a specific key path asynchronously.\n- `getSync\u003cT extends valueTypes\u003e(keyPath?: KeyPath): T`: Gets the value at a specific key path synchronously.\n- `set\u003cT extends valueTypes\u003e(...args: [Types\u003cT\u003e] | [KeyPath, T]): Promise\u003cvoid\u003e`: Sets a value at a specific key path asynchronously.\n- `setSync\u003cT extends valueTypes\u003e(...args: [Types\u003cT\u003e] | [KeyPath, T]): void`: Sets a value at a specific key path synchronously.\n- `unset(keyPath?: KeyPath): Promise\u003cvoid\u003e`: Removes a key-value pair at a specific key path asynchronously.\n- `unsetSync(keyPath?: KeyPath): void`: Removes a key-value pair at a specific key path synchronously.\n___\n### Fields\n- `options: Options`: The configuration options for the `KeyValues` instance.\n- `fnc: Functions`: An instance of the `Functions` class used for file operations and data manipulation.\n\n\n## Dependencies\n\n- [lodash](https://lodash.com/): The Lodash library exported as Node.js modules.\n- [write-file-atomic](https://github.com/npm/write-file-atomic): Atomically and asynchronously writes data to a file, replacing the file if it already exists. data can be a string or a buffer\n\n\n# Contributing\n\nPlease make sure to read the [Contributing Guide](docs/CONTRIBUTING.md) before making a pull request.\n\n\nThank you to all the people who already contributed to project!\n\n\u003ca href=\"https://github.com/heliomarpm/keyvalues-storage/graphs/contributors\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=heliomarpm/keyvalues-storage\" /\u003e\n\u003c/a\u003e\n\n###### Made with [contrib.rocks](https://contrib.rocks).\n\nThat said, there's a bunch of ways you can contribute to this project, like by:\n\n- :beetle: Reporting a bug\n- :page_facing_up: Improving this documentation\n- :rotating_light: Sharing this project and recommending it to your friends\n- :dollar: Supporting this project on GitHub Sponsors or Ko-fi\n- :star2: Giving a star on this repository\n\n\n## Donate\n\nIf you appreciate that, please consider donating to the Developer.\n\n\u003cp\u003e\n  \u003c!-- PixMe --\u003e\n  \u003ca href=\"https://www.pixme.bio/heliomarpm\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n    \u003cimg alt=\"pixme url\" src=\"https://img.shields.io/badge/donate%20on-pixme-1C1E26?style=for-the-badge\u0026labelColor=1C1E26\u0026color=28f4f4\"/\u003e\n  \u003c/a\u003e\n  \u003c!-- PayPal --\u003e\n  \u003ca href=\"https://bit.ly/paypal-sponsor-heliomarpm\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n    \u003cimg alt=\"paypal url\" src=\"https://img.shields.io/badge/paypal-1C1E26?style=for-the-badge\u0026labelColor=1C1E26\u0026color=0475fe\"/\u003e\n  \u003c/a\u003e\n  \u003c!-- Ko-fi --\u003e\n  \u003ca href=\"https://ko-fi.com/heliomarpm\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n    \u003cimg alt=\"kofi url\" src=\"https://img.shields.io/badge/kofi-1C1E26?style=for-the-badge\u0026labelColor=1C1E26\u0026color=ff5f5f\"/\u003e\n  \u003c/a\u003e\n  \u003c!-- LiberaPay --\u003e  \n  \u003ca href=\"https://liberapay.com/heliomarpm\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n     \u003cimg alt=\"liberapay url\" src=\"https://img.shields.io/badge/liberapay-1C1E26?style=for-the-badge\u0026labelColor=1C1E26\u0026color=f6c915\"/\u003e\n  \u003c/a\u003e  \n  \u003c!-- GitHub Sponsors --\u003e\n  \u003ca href=\"https://github.com/sponsors/heliomarpm\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n    \u003cimg alt=\"github sponsors url\" src=\"https://img.shields.io/badge/GitHub%20-Sponsor-1C1E26?style=for-the-badge\u0026labelColor=1C1E26\u0026color=db61a2\"/\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## License\n\n[MIT © Heliomar P. Marques](LICENSE) \u003ca href=\"#top\"\u003e🔝\u003c/a\u003e\n\n\n----\n[url-npm]: https://www.npmjs.com/package/@heliomarpm/kvs\n[url-npm-badge]: https://img.shields.io/npm/v/@heliomarpm/kvs.svg\n[url-downloads-badge]: https://img.shields.io/npm/dm/@heliomarpm/kvs.svg\n[url-downloads]: http://badge.fury.io/js/@heliomarpm/kvs.svg\n[url-deepscan-badge]: https://deepscan.io/api/teams/19612/projects/25344/branches/791226/badge/grade.svg\n[url-deepscan]: https://deepscan.io/dashboard#view=project\u0026tid=19612\u0026pid=25344\u0026bid=791226\n[url-codefactor-badge]: https://www.codefactor.io/repository/github/heliomarpm/keyvalues-storage/badge\n[url-codefactor]: https://www.codefactor.io/repository/github/heliomarpm/keyvalues-storage\n[url-codeql]: https://github.com/heliomarpm/keyvalues-storage/actions/workflows/codeql.yml/badge.svg \n[url-publish]: https://github.com/heliomarpm/keyvalues-storage/actions/workflows/publish.yml/badge.svg \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheliomarpm%2Fkeyvalues-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheliomarpm%2Fkeyvalues-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheliomarpm%2Fkeyvalues-storage/lists"}