{"name":"rc9","version":"2.0.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"}},"main":"./dist/index.cjs","types":"./dist/index.d.ts","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"},"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","gitHead":"d993e871740869baa7885cded9be8ef2030b14fd","bugs":{"url":"https://github.com/unjs/rc9/issues"},"homepage":"https://github.com/unjs/rc9#readme","_id":"rc9@2.0.0","_nodeVersion":"14.20.1","_npmVersion":"6.14.17","dist":{"integrity":"sha512-yVeYJHOpJLOhs3V6RKwz7RPPwPurrx3JjwK264sPgvo/lFdhuUrLien7iSvAO6STVkN0gSMk/MehQNHQhflqZw==","shasum":"932d6f398f901529b4cc6c2037af3e4ba220d82b","tarball":"http://registry-npm.ywwl.com/rc9/download/rc9-2.0.0.tgz","fileCount":7,"unpackedSize":14683,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCuH9yqcup6Pcel7ae9WG99Cqx/y3U8kxWoVXAH4qAVFAIhAIix6IMiOo+GvG251xIMrCbBFWsK+SfzB4MzCOqZ3Jg1"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjc2I5ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo+MRAAn70vB6FBmureze/aASZDMI2aY2Hh0iVf9se/jMm5RggkrqeF\r\nU/f6l/+0dlWEVlZ+r7fhrlm0pcn04ehz5dR2othU65yTvLAPhtQNeRQ5uyC0\r\nkKKxg+MHHz9/68GfWHQWXzkZITv7R8V5FHQpuP8C/kt5AM9zQxOliytr44pX\r\nW3xnL1XYEbZUSu9piHzzKejBoqtWY5PRMez8HRAdxkhVyr9b5tO0RpjVimDp\r\n75vXxjLiLdtgaHszArSVOb29JGZY+pKnEKTf3hRDjFd54Nm9iftxbb9nBg9j\r\nyo5g6PG1ax2vlEz+ZqMGZ4nUuaV000n6yu8AzdxnIRvmbD5+fTTc0w1cjnbD\r\nUs7JzhrXb5TkP/jSBX4ziaREBN14nJiQxdPqY2Fs+T3UEZmeqbQhw1TSMoak\r\nyjUEpgoVwpSksjIl+HAXqf0TfuQMqmORD/G0W6aU1L8JRt7cB/mimiWaRMbG\r\n7n0fkc2L6BjZ1SFF8aK/bkaLSvqERX/t9MhSeNEeWLvfFeMFrFExuK2R5NuE\r\ncmiK/1gehfJIjqnO19t6d5KqW/fDZkTytnhmR4LlyrMPFLupnDLZzeMjKUiX\r\n653ZMRwDYYDSN+dEMLxpHeRgqtXsRRJPDmMg1OUoVWXfEQGvU/ThFFDz6xx3\r\nDF1LuzbLEAihEZuuZyvohMFtJYLHYiqKPWw=\r\n=s51d\r\n-----END PGP SIGNATURE-----\r\n","size":4784,"noattachment":false,"key":"/rc9/-/rc9-2.0.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.0.0_1668506169271_0.18691002668070555"},"_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":1668506169402,"_cnpm_publish_time":1668506169402,"dist-tags":{"1x":"1.2.4","latest":"3.1.0"}}