{"name":"rc9","version":"3.0.0","license":"MIT","_id":"rc9@3.0.0","maintainers":[{"name":"pi0","email":"pyapar@gmail.com"}],"homepage":"https://github.com/unjs/rc9#readme","bugs":{"url":"https://github.com/unjs/rc9/issues"},"dist":{"shasum":"0325b85d9c2fe55387072359ad6b78f28915d4a6","tarball":"http://registry-npm.ywwl.com/rc9/download/rc9-3.0.0.tgz","fileCount":6,"integrity":"sha512-MGOue0VqscKWQ104udASX/3GYDcKyPI4j4F8gu/jHHzglpmy9a/anZK3PNe8ug6aZFl+9GxLtdhe3kVZuMaQbA==","signatures":[{"sig":"MEQCIBChNnyu4pqq4DUKKhAKAKkuUUY4yL2FhCPmc0GTdDmIAiBryVZ0Ihj15yIzEefzKt4hYs3yrmE1skOCO9GYLvzVfg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14762,"size":5516,"noattachment":false,"key":"/rc9/-/rc9-3.0.0.tgz"},"main":"./dist/index.mjs","type":"module","types":"./dist/index.d.mts","exports":{".":"./dist/index.mjs"},"gitHead":"4f6d3d4a6087d0d874b9ffd820f4559da03f38e0","scripts":{"dev":"vitest","lint":"oxlint . && oxfmt --check src test","test":"pnpm lint && pnpm typecheck && vitest run --coverage","build":"obuild","format":"oxlint . --fix && oxfmt src test","release":"pnpm test && pnpm build && changelogen --release --push && npm publish","typecheck":"tsgo --noEmit"},"_npmUser":{"name":"pi0","email":"pyapar@gmail.com"},"repository":{"url":"git+https://github.com/unjs/rc9.git","type":"git"},"_npmVersion":"11.6.2","description":"Read/Write config couldn't be easier!","directories":{},"sideEffects":false,"_nodeVersion":"24.13.0","dependencies":{"defu":"^6.1.4","destr":"^2.0.5"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.28.2","devDependencies":{"flat":"^6.0.1","oxfmt":"^0.28.0","automd":"^0.4.3","obuild":"^0.4.25","oxlint":"^1.43.0","vitest":"^4.0.18","@types/node":"^25.2.1","changelogen":"^0.6.2","@vitest/coverage-v8":"^4.0.18","@typescript/native-preview":"^7.0.0-dev.20260206.1"},"_npmOperationalInternal":{"tmp":"tmp/rc9_3.0.0_1770380195693_0.8198906447944749","host":"s3://npm-registry-packages-npm-production"},"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://npm.chart.dev/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 add rc9\n\n# bun\nbun install rc9\n\n# deno\ndeno install npm:rc9\n```\n\n<!-- /automd -->\n\nImport utils:\n\n<!-- automd:jsimport src=\"./src/index.ts\"-->\n\n**ESM** (Node.js, Bun, Deno)\n\n```js\nimport {\n  defaults,\n  parse,\n  parseFile,\n  read,\n  readUser,\n  serialize,\n  write,\n  writeUser,\n  userConfigDir,\n  readUserConfig,\n  writeUserConfig,\n  updateUserConfig,\n  update,\n  updateUser,\n} from \"rc9\";\n```\n\n<!-- /automd -->\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\nYou can use `readUserConfig`/`writeUserConfig`/`updateUserConfig` to store config in the user's config directory (`$XDG_CONFIG_HOME` or `~/.config`):\n\n```js\nwriteUserConfig({ token: 123 }, \".zoorc\"); // Will be saved in ~/.config/.zoorc\n\nconst conf = readUserConfig(\".zoorc\"); // { token: 123 }\n```\n\nThe config directory is created if it doesn't exist. Use `userConfigDir()` if you need to know where a value was written.\n\n> [!NOTE]\n> `readUser`/`writeUser`/`updateUser` are deprecated. Use `readUserConfig`/`writeUserConfig`/`updateUserConfig` instead, which follow XDG conventions (`~/.config`).\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 readUserConfig(options?: RCOptions | string): RC;\nfunction userConfigDir(): string;\nfunction serialize(config: RC): string;\nfunction write(config: RC, options?: RCOptions | string): void;\nfunction writeUserConfig(config: RC, options?: RCOptions | string): void;\nfunction update(config: RC, options?: RCOptions | string): RC;\nfunction updateUserConfig(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":1770380195847,"_cnpm_publish_time":1770380195847,"dist-tags":{"1x":"1.2.4","latest":"3.1.0"}}