{"name":"rc9","version":"1.2.3","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"}},"main":"./dist/index.cjs","types":"./dist/index.d.ts","dependencies":{"defu":"^6.1.1","destr":"^1.2.1","flat":"^5.0.2"},"devDependencies":{"@types/flat":"^5.0.2","@types/node":"^18.11.9","@vitest/coverage-c8":"^0.25.2","eslint":"^8.27.0","eslint-config-unjs":"^0.0.2","standard-version":"^9.5.0","typescript":"^4.8.4","unbuild":"^0.9.4","vitest":"^0.25.2"},"packageManager":"pnpm@7.16.0","scripts":{"build":"unbuild","dev":"vitest","lint":"eslint --ext .ts .","release":"pnpm test && pnpm build && standard-version && git push --follow-tags && pnpm publish","test":"pnpm lint && vitest run --coverage"},"bugs":{"url":"https://github.com/unjs/rc9/issues"},"homepage":"https://github.com/unjs/rc9#readme","_id":"rc9@1.2.3","_integrity":"sha512-nw2fMaR5c0BrQB41+mK+AB6oytKQzY9K4wkPyUeNOg6yzn0wzT01JqivtRoTT/bGduUg8R/Zx4rFEqEm0jZTZA==","_resolved":"/private/var/folders/s0/k4lcb4b50bj9r4fch4_1h_l40000gn/T/5abf13d49e4f900d2087e8ff0578466e/rc9-1.2.3.tgz","_from":"file:rc9-1.2.3.tgz","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-nw2fMaR5c0BrQB41+mK+AB6oytKQzY9K4wkPyUeNOg6yzn0wzT01JqivtRoTT/bGduUg8R/Zx4rFEqEm0jZTZA==","shasum":"534c35b3d2ca75f8247ef43a9ee945d080608ea8","tarball":"http://registry-npm.ywwl.com/rc9/download/rc9-1.2.3.tgz","fileCount":6,"unpackedSize":12095,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHAQ66kqU+RlyCWD2D3+d9BT94TSBZJaVmZZtAA6LppWAiAbtMGXF71doKNDSo8T988W/qTVkhnDgQl+LoPceVb0lg=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjctcXACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoZqA/+O//+JG/d12e59dQ0sjlxiNg0GuTJVfVeCuNUFs/ECH+XxvkL\r\n2mMV9gWSDWdF6ZMpnr0mnysk+zOe2jbw7rHS0uoiWpS54ImWLjo7emDf3Ii3\r\nW0mER5yoPTIM32nD6vSM22EtkU+sZF1Llqj54QlIf2tj9cOwQV6hXy4dO5F+\r\nsVpGL0rvRtemgfEo0g360suwSvgT/2mmrW1tuZ0mn9LnEVn20XXqGxyvgDFj\r\nANs9LBRuXIEqKnHKQfdz2oU+MuenSIsxI6ei+09I4Ed4jASBtjPX0N5sO2E+\r\nsFQ75oMHMm8YrgWu5CVQUoUXiYlQfwN5rjrxwWrgIgvnkAoX8glIissnqE4A\r\neaY7g+I8/1H/EICfnfMZ3cYcoX+GRz+Pu1jiOfZhzvGbb3n64GAnCaLgAWnO\r\n8UN/uM86J1FM1Hl3LfCSqWljZPtVK0qQFc0OMPtNIRD3qBHzp41NBtU/8Qcm\r\n73Qjn6jdMfM9H186XoqRJVhKbO1vo/ZOqcC1AfH3BOHX2A3wkxQgkx+Kh8tE\r\ncP1VYsCeBxOaVb7iyw9RZwBQr3g7pjzTciJFQ/bpLbNopwXdlO1VvT5ikKgJ\r\nXyuBAIQ8iBJ0Q/HLFIY5NMOUfFY8kqIbwq96O+9OiIciYTnP/JemSXNUcnee\r\n7ORxnDsdrFqB743bjEgTXf3T7Iwii+etclQ=\r\n=sjUX\r\n-----END PGP SIGNATURE-----\r\n","size":3885,"noattachment":false,"key":"/rc9/-/rc9-1.2.3.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_1.2.3_1668470551297_0.5254817069008426"},"_hasShrinkwrap":false,"deprecated":"includes breaking changes","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":1668470551526,"_cnpm_publish_time":1668470551526,"dist-tags":{"1x":"1.2.4","latest":"3.1.0"}}