{"name":"rc9","version":"2.1.0","description":"Read/Write config couldn't be easier!","repository":{"type":"git","url":"git+https://github.com/unjs/rc9.git"},"license":"MIT","sideEffects":false,"exports":{".":{"require":"./dist/index.cjs","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"main":"./dist/index.cjs","types":"./dist/index.d.ts","scripts":{"build":"unbuild","dev":"vitest","lint":"eslint --ext .ts . && prettier -c src test","release":"pnpm test && pnpm build && changelogen --release --push && npm publish","test":"pnpm lint && vitest run --coverage"},"dependencies":{"defu":"^6.1.2","destr":"^1.2.2","flat":"^5.0.2"},"devDependencies":{"@types/flat":"^5.0.2","@types/node":"^18.15.11","@vitest/coverage-c8":"^0.29.8","changelogen":"^0.5.2","eslint":"^8.37.0","eslint-config-unjs":"^0.1.0","prettier":"^2.8.7","typescript":"^5.0.2","unbuild":"^1.1.2","vitest":"^0.29.8"},"packageManager":"pnpm@8.0.0","gitHead":"5b37325191aba45004a55d3cd07af1302a49286c","bugs":{"url":"https://github.com/unjs/rc9/issues"},"homepage":"https://github.com/unjs/rc9#readme","_id":"rc9@2.1.0","_nodeVersion":"16.19.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-ROO9bv8PPqngWKoiUZU3JDQ4sugpdRs9DfwHnzDSxK25XtQn6BEHL6EOd/OtKuDT2qodrtNR+0WkPT6l0jxH5Q==","shasum":"57d3a01e55907393ef9bd0cc29f2bd66a6cd0972","tarball":"http://registry-npm.ywwl.com/rc9/download/rc9-2.1.0.tgz","fileCount":6,"unpackedSize":12394,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDLMSdEzKztJ615d9i/A5I7/rJDmdbwlmVzTUyxVgMR8wIhAPAzgwMxGUpnFu3oL2dQ74dQUYFGGqi1DRcCpsnq9hKB"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkJW8TACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrbQg/+P/aTSpwqsTV18D+rRPBPwGgaUxrYa35toHUe8GEYmdnv8b+d\r\n7x6SzYvJLD1bMBEouc7gCHqQHdDI/rt2lNKqWwlMIupoiARMeYw3uxwk+4l/\r\nS98WTrCkU2/6omKpByfSGqJvd1G8l1qJz8TJbTGjj78vr9yWAwjafE3DPk5l\r\nB9hV3lS33KqS+Lwu39hoaKmoqnP0av0UR8Vhuw33tTyLq4i1KFs7triUP+fI\r\nKAlKQIFUB6C31w7EqVylMd5nRRXiOgapfgh3J6cULxgG8oinYoFcw+uns5zw\r\nb0HweTMTVG4h1fnkfsqjwutDRPtKFKgjwfXEbfz6ZDAoQfrJgvU1Y9be6vRU\r\nj7+TP4rgc3eUCoqvZUNUNquFs0q0k8zKpZRXfHvnCjvEEm8c0StnbdXRLkDv\r\nD01K9eL+iJwjP8fGdbOvGzqYNImRCi/HIH7IAvgK+w9eleirDMRT3LqilAJl\r\naxuBvlPXLY2dPjLfhU0istdc/w1yWC8u0RwNwvY56AWguWZJLdaaVKTKa56I\r\nZKl3qiJyqZzD4g5ne+DUTV2QqHnLPioHv5wxcQwewvyO+gTegcfCwkHxpi0d\r\n1ucZ/P3jjB/oaljsvtJBcWFCHAqVIG02wy3IluxRTHCzG4HcgSggh7PygWC9\r\nRZK8+Jmp6Wo5t41fULwOkK/sSBHkcleZHeM=\r\n=jIeH\r\n-----END PGP SIGNATURE-----\r\n","size":3936,"noattachment":false,"key":"/rc9/-/rc9-2.1.0.tgz"},"_npmUser":{"name":"pi0","email":"pyapar@gmail.com"},"directories":{},"maintainers":[{"name":"pi0","email":"pyapar@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rc9_2.1.0_1680174866896_0.4855719302089332"},"_hasShrinkwrap":false,"readme":"# RC9\n\n<!-- automd:badges color=yellow codecov bundlejs -->\n\n[![npm version](https://img.shields.io/npm/v/rc9?color=yellow)](https://npmjs.com/package/rc9)\n[![npm downloads](https://img.shields.io/npm/dm/rc9?color=yellow)](https://npmjs.com/package/rc9)\n[![bundle size](https://img.shields.io/bundlejs/size/rc9?color=yellow)](https://bundlejs.com/?q=rc9)\n[![codecov](https://img.shields.io/codecov/c/gh/unjs/rc9?color=yellow)](https://codecov.io/gh/unjs/rc9)\n\n<!-- /automd -->\n\nRead/Write RC configs couldn't be easier!\n\n## Install\n\nInstall dependencies:\n\n<!-- automd:pm-i -->\n\n```sh\n# ✨ Auto-detect\nnpx nypm install rc9\n\n# npm\nnpm install rc9\n\n# yarn\nyarn add rc9\n\n# pnpm\npnpm install rc9\n\n# bun\nbun install rc9\n```\n\n<!-- /automd -->\n\nImport utils:\n\n<!-- automd:jsimport cjs src=\"./src/index.ts\"-->\n\n**ESM** (Node.js, Bun)\n\n```js\nimport {\n  defaults,\n  parse,\n  parseFile,\n  read,\n  readUser,\n  serialize,\n  write,\n  writeUser,\n  update,\n  updateUser,\n} from \"rc9\";\n```\n\n**CommonJS** (Legacy Node.js)\n\n```js\nconst {\n  defaults,\n  parse,\n  parseFile,\n  read,\n  readUser,\n  serialize,\n  write,\n  writeUser,\n  update,\n  updateUser,\n} = require(\"rc9\");\n```\n\n<!-- /automd -->\n\n\n## Usage\n\n`.conf`:\n\n```ini\ndb.username=username\ndb.password=multi word password\ndb.enabled=true\n```\n\n**Update config:**\n\n```ts\nupdate({ 'db.enabled': false }) // or update(..., { name: '.conf' })\n```\n\nPush to an array:\n\n```ts\nupdate({ 'modules[]': 'test' })\n```\n\n**Read/Write config:**\n\n```ts\nconst config = read() // or read('.conf')\n\n// config = {\n//   db: {\n//     username: 'username',\n//     password: 'multi word password',\n//     enabled: true\n//   }\n// }\n\nconfig.enabled = false\nwrite(config) // or write(config, '.conf')\n```\n\n**User Config:**\n\nIt is common to keep config in user home directory (MacOS: `/Users/{name}`, Linux: `/home/{name}`, Windows: `C:\\users\\{name}`)\n\nyou can use `readUser`/`writeuser`/`updateUser` shortcuts to quickly do this:\n\n```js\nwriteUser({ token: 123 }, '.zoorc') // Will be saved in {home}/.zoorc\n\nconst conf = readUser('.zoorc') // { token: 123 }\n```\n\n## Unflatten\n\nRC uses [flat](https://www.npmjs.com/package/flat) to automatically flat/unflat when writing and reading rcfile.\n\nIt means that you can use `.` for keys to define objects. Some examples:\n\n- `hello.world = true` <=> `{ hello: { world: true }`\n- `test.0 = A` <=> `tags: [ 'A' ]`\n\n**Note:** If you use keys that can override like `x=` and `x.y=`, you can disable this feature by passing `flat: true` option.\n\n**Tip:** You can use keys ending with `[]` to push to an array like `test[]=A`\n\n## Native Values\n\nRC uses [destr](https://www.npmjs.com/package/destr) to convert values into native javascript values.\n\nSo reading `count=123` results `{ count: 123 }` (instead of `{ count: \"123\" }`) if you want to preserve strings as is, can use `count=\"123\"`.\n\n## Exports\n\n```ts\nconst defaults: RCOptions;\nfunction parse(contents: string, options?: RCOptions): RC\nfunction parseFile(path: string, options?: RCOptions): RC\nfunction read(options?: RCOptions | string): RC;\nfunction readUser(options?: RCOptions | string): RC;\nfunction serialize(config: RC): string;\nfunction write(config: RC, options?: RCOptions | string): void;\nfunction writeUser(config: RC, options?: RCOptions | string): void;\nfunction update(config: RC, options?: RCOptions | string): RC;\nfunction updateUser(config: RC, options?: RCOptions | string): RC;\n```\n\n**Types:**\n\n```ts\ntype RC = Record<string, any>;\ninterface RCOptions {\n    name?: string;\n    dir?: string;\n    flat?: boolean;\n}\n```\n\n**Defaults:**\n\n```ini\n{\n  name: '.conf',\n  dir: process.cwd(),\n  flat: false\n}\n```\n\n### Why RC9?\n\nBe the first one to guess 🐇 <!-- Hint: do research about rc files history -->\n\n## License\n\n<!-- automd:contributors license=MIT -->\n\nPublished under the [MIT](https://github.com/unjs/rc9/blob/main/LICENSE) license.\nMade by [community](https://github.com/unjs/rc9/graphs/contributors) 💛\n<br><br>\n<a href=\"https://github.com/unjs/rc9/graphs/contributors\">\n<img src=\"https://contrib.rocks/image?repo=unjs/rc9\" />\n</a>\n\n<!-- /automd -->\n","publish_time":1680174867030,"_cnpm_publish_time":1680174867030,"dist-tags":{"1x":"1.2.4","latest":"3.1.0"}}