{"name":"rc9","version":"3.0.1","license":"MIT","_id":"rc9@3.0.1","maintainers":[{"name":"pi0","email":"pyapar@gmail.com"}],"homepage":"https://github.com/unjs/rc9#readme","bugs":{"url":"https://github.com/unjs/rc9/issues"},"dist":{"shasum":"3895e5834a2b5c2d8fb76d93e802fbcbc2579bc7","tarball":"http://registry-npm.ywwl.com/rc9/download/rc9-3.0.1.tgz","fileCount":7,"integrity":"sha512-gMDyleLWVE+i6Sgtc0QbbY6pEKqYs97NGi6isHQPqYlLemPoO8dxQ3uGi0f4NiP98c+jMW6cG1Kx9dDwfvqARQ==","signatures":[{"sig":"MEQCIDHay6nmqSzpoECnxzMKjAx3Kn8V6/FV48l+kMPq3AcBAiAvSYfAkD172AAZuyuq4Ng0NnMpiff/csuS5fEsjWge3w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":25678,"size":6512,"noattachment":false,"key":"/rc9/-/rc9-3.0.1.tgz"},"main":"./dist/index.mjs","type":"module","types":"./dist/index.d.mts","exports":{".":"./dist/index.mjs"},"gitHead":"3df7dc63d21034f739fb13066546d4a6c44950c7","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.6","destr":"^2.0.5"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.33.0","devDependencies":{"flat":"^6.0.1","oxfmt":"^0.43.0","automd":"^0.4.3","obuild":"^0.4.32","oxlint":"^1.58.0","vitest":"^4.1.2","typescript":"^6.0.2","@types/node":"^25.5.0","changelogen":"^0.6.2","@vitest/coverage-v8":"^4.1.2","@typescript/native-preview":"^7.0.0-dev.20260401.1"},"_npmOperationalInternal":{"tmp":"tmp/rc9_3.0.1_1775069089776_0.1346360239657669","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":1775069089913,"_cnpm_publish_time":1775069089913,"dist-tags":{"1x":"1.2.4","latest":"3.1.0"}}