CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
readme.md128 linesDownload Raw Back to configstore
1# configstore2 3> Easily load and persist config without having to think about where and how4 5The config is stored in a JSON file located in `$XDG_CONFIG_HOME` or `~/.config`.\6Example: `~/.config/configstore/some-id.json`7 8*If you need this for Electron, check out [`electron-store`](https://github.com/sindresorhus/electron-store) instead.*\9*And check out [`conf`](https://github.com/sindresorhus/conf) for a more modern version of `configstore`.*10 11## Install12 13```sh14npm install configstore15```16 17## Usage18 19```js20import fs from 'node:fs';21import Configstore from 'configstore';22 23const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));24 25// Create a Configstore instance.26const config = new Configstore(packageJson.name, {foo: 'bar'});27 28console.log(config.get('foo'));29//=> 'bar'30 31config.set('awesome', true);32console.log(config.get('awesome'));33//=> true34 35// Use dot-notation to access nested properties.36config.set('bar.baz', true);37console.log(config.get('bar'));38//=> {baz: true}39 40config.delete('awesome');41console.log(config.get('awesome'));42//=> undefined43```44 45## API46 47### Configstore(packageName, defaults?, options?)48 49Returns a new instance.50 51#### packageName52 53Type: `string`54 55Name of your package.56 57#### defaults58 59Type: `object`60 61Default config.62 63#### options64 65Type: `object`66 67##### globalConfigPath68 69Type: `boolean`\70Default: `false`71 72Store 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.73 74##### configPath75 76Type: `string`\77Default: Automatic78 79**Please don't use this option unless absolutely necessary and you know what you're doing.**80 81Set the path of the config file. Overrides the `packageName` and `globalConfigPath` options.82 83### Instance84 85You can use [dot-notation](https://github.com/sindresorhus/dot-prop) in a `key` to access nested properties.86 87### .set(key, value)88 89Set an item.90 91### .set(object)92 93Set multiple items at once.94 95### .get(key)96 97Get an item.98 99### .has(key)100 101Check if an item exists.102 103### .delete(key)104 105Delete an item.106 107### .clear()108 109Delete all items.110 111### .size112 113Get the item count.114 115### .path116 117Get 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.118 119### .all120 121Get all the config as an object or replace the current config with an object:122 123```js124config.all = {125	hello: 'world'126};127```128 
basant307/AI_Governance_Project · CoolFace