{"name":"configstore","version":"8.0.0","description":"Easily load and save config without having to think about where and how","license":"BSD-2-Clause","repository":{"type":"git","url":"git+https://github.com/sindresorhus/configstore.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","types":"./index.d.ts","sideEffects":false,"engines":{"node":">=20"},"scripts":{"test":"xo && ava"},"keywords":["config","store","storage","configuration","settings","preferences","json","data","persist","persistent","save"],"dependencies":{"atomically":"^2.1.0","dot-prop":"^10.1.0","graceful-fs":"^4.2.11","is-safe-filename":"^0.1.0","xdg-basedir":"^5.1.0"},"devDependencies":{"ava":"^6.4.1","xo":"^1.2.3"},"ava":{"serial":true},"gitHead":"f21e8f88f78d17b12bef79c6e36b6a49e8f42a9e","_id":"configstore@8.0.0","bugs":{"url":"https://github.com/sindresorhus/configstore/issues"},"homepage":"https://github.com/sindresorhus/configstore#readme","_nodeVersion":"25.3.0","_npmVersion":"11.7.0","dist":{"integrity":"sha512-U51WPZg+o6FDFhBCV6yYFEspGMCoHvCgJSGFw9AwsW2u75gYBPoDlYca5XfDs4TdMUu3/y0R6FFdvvgyH31mKQ==","shasum":"2c02dded7d3183b62841c04a207ab9c5bb8ceb90","tarball":"http://registry-npm.ywwl.com/configstore/download/configstore-8.0.0.tgz","fileCount":5,"unpackedSize":11331,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDKiHmbE1lwmkaivOSKkZbd8kpgmd8yeoDGiSsOe5RhJAiA9PBuoQxQ+4jr2YbKo3ZK9wolAX4udQiAW/3WA4NX4Gg=="}],"size":4064,"noattachment":false,"key":"/configstore/-/configstore-8.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/configstore_8.0.0_1769260372307_0.18854101599077455"},"_hasShrinkwrap":false,"readme":"# configstore\n\n> Easily load and persist config without having to think about where and how\n\nThe config is stored in a JSON file located in `$XDG_CONFIG_HOME` or `~/.config`.\\\nExample: `~/.config/configstore/some-id.json`\n\n*If you need this for Electron, check out [`electron-store`](https://github.com/sindresorhus/electron-store) instead.*\\\n*And check out [`conf`](https://github.com/sindresorhus/conf) for a more modern version of `configstore`.*\n\n## Install\n\n```sh\nnpm install configstore\n```\n\n## Usage\n\n```js\nimport fs from 'node:fs';\nimport Configstore from 'configstore';\n\nconst packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));\n\n// Create a Configstore instance.\nconst config = new Configstore(packageJson.name, {foo: 'bar'});\n\nconsole.log(config.get('foo'));\n//=> 'bar'\n\nconfig.set('awesome', true);\nconsole.log(config.get('awesome'));\n//=> true\n\n// Use dot-notation to access nested properties.\nconfig.set('bar.baz', true);\nconsole.log(config.get('bar'));\n//=> {baz: true}\n\n// Handle missing keys with nullish coalescing.\nconsole.log(config.get('nonexistent') ?? 'default value');\n//=> 'default value'\n\nconfig.delete('awesome');\nconsole.log(config.get('awesome'));\n//=> undefined\n```\n\n## API\n\n### Configstore(id, defaults?, options?)\n\nReturns a new instance.\n\n#### id\n\nType: `string`\n\nIdentifier for your config. Usually your package name.\n\n#### defaults\n\nType: `object`\n\nDefault config.\n\n#### options\n\nType: `object`\n\n##### globalConfigPath\n\nType: `boolean`\\\nDefault: `false`\n\nStore the config at `$CONFIG/package-name/config.json` instead of the default `$CONFIG/configstore/package-name.json`. This is not recommended as you might end up conflicting with other tools, rendering the \"without having to think\" idea moot.\n\n##### configPath\n\nType: `string`\\\nDefault: Automatic\n\n**Please don't use this option unless absolutely necessary and you know what you're doing.**\n\nSet the path of the config file. Overrides the `id` and `globalConfigPath` options.\n\n##### clearInvalidConfig\n\nType: `boolean`\\\nDefault: `true`\n\nClear the config file if it contains invalid JSON. If set to `false`, a `SyntaxError` will be thrown instead of clearing the file. This allows you to recover corrupted config files manually.\n\n### Instance\n\nYou can use [dot-notation](https://github.com/sindresorhus/dot-prop) in a `key` to access nested properties.\n\n### .set(key, value)\n\nSet an item.\n\nYou can use [dot-notation](https://github.com/sindresorhus/dot-prop) in a `key` to access nested properties.\n\n### .set(object)\n\nSet multiple items at once.\n\n### .get(key)\n\nGet an item.\n\nYou can use [dot-notation](https://github.com/sindresorhus/dot-prop) in a `key` to access nested properties.\n\n> [!TIP]\n> Use the [nullish coalescing operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing) (`??`) to provide default values:\n> ```js\n> const value = config.get('key') ?? 'default value';\n> ```\n\n### .has(key)\n\nCheck if an item exists.\n\nYou can use [dot-notation](https://github.com/sindresorhus/dot-prop) in a `key` to access nested properties.\n\n### .delete(key)\n\nDelete an item.\n\nYou can use [dot-notation](https://github.com/sindresorhus/dot-prop) in a `key` to access nested properties.\n\n### .clear()\n\nDelete all items.\n\n### .size\n\nGet the item count.\n\n### .path\n\nGet the path to the config file. Can be used to show the user where the config file is located or even better open it for them.\n\n### .all\n\nGet all the config as an object or replace the current config with an object.\n\n```js\nconsole.log(config.all);\n//=> {foo: 'bar', hello: 'world'}\n\nconfig.all = {\n\thello: 'world'\n};\n```\n","publish_time":1769260372443,"_cnpm_publish_time":1769260372443,"dist-tags":{"latest":"8.0.0","legacy-v3":"3.1.5"}}