{"_id":"@ambiere/to-object","name":"@ambiere/to-object","dist-tags":{"latest":"0.3.0"},"versions":{"0.3.0":{"name":"@ambiere/to-object","version":"0.3.0","description":"Parse string representations of objects into JavaScript objects.","main":"src/index.js","type":"module","funding":"https://github.com/sponsors/ambiere","types":"./src/types/index.d.ts","exports":{"types":"./src/types/index.d.ts","default":"./src/index.js"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/ambiere/to-object.git"},"keywords":["Parse","javascript","object","string","JSON"],"author":{"name":"Zidikhery Mchomvu","email":"itsambiere@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/ambiere/to-object/issues"},"homepage":"https://github.com/ambiere/to-object#readme","devDependencies":{"tap":"^18.7.0"},"_id":"@ambiere/to-object@0.3.0","gitHead":"1511fbe54e47d2029928cf660adf9ed09a62b816","_nodeVersion":"21.6.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-JwqupuRK7W0+gRKF21RO6d97BroX7tkCre/NDllS2ciPbvTzGIClwt2SWpILJyN9uMdO/T/V+slITjLc3VS5hg==","shasum":"f25d830d6943bba0acfb69497f581a1956f123dc","tarball":"https://registry.npmjs.org/@ambiere/to-object/-/to-object-0.3.0.tgz","fileCount":9,"unpackedSize":7148,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCFkR0Yjdef4wZLBmy97JqjA4YLAXZd3BkAKHTojMzchgIhAJj5XITYqKcN2V4/TP4D6ntDO8lQ2RsWhkjdm72uCjrN"}]},"_npmUser":{"name":"ambiere","email":"itsambiere@gmail.com"},"directories":{},"maintainers":[{"name":"ambiere","email":"itsambiere@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/to-object_0.3.0_1713374191228_0.8684092203843379"},"_hasShrinkwrap":false}},"time":{"created":"2024-04-17T17:16:31.057Z","0.3.0":"2024-04-17T17:16:31.409Z","modified":"2024-04-17T17:16:31.762Z"},"maintainers":[{"name":"ambiere","email":"itsambiere@gmail.com"}],"description":"Parse string representations of objects into JavaScript objects.","homepage":"https://github.com/ambiere/to-object#readme","keywords":["Parse","javascript","object","string","JSON"],"repository":{"type":"git","url":"git+https://github.com/ambiere/to-object.git"},"author":{"name":"Zidikhery Mchomvu","email":"itsambiere@gmail.com"},"bugs":{"url":"https://github.com/ambiere/to-object/issues"},"license":"MIT","readme":"# to-object [![ci](https://github.com/ambiere/to-object/actions/workflows/main.yml/badge.svg)](https://github.com/ambiere/to-object/actions/workflows/main.yml)\n\n>Lightweight utility package designed to simplify—\n<br>the process of parsing string representations of objects into JavaScript objects.\n\nAs implemented in [next-clsx](https://github.com/ambiere/clsx)\n\n>contents <br>1. [Installattion](#Installattion)<br>2. [Use case](#Use-case)<br>3. [License](#License)\n\n\n## Installattion\n\n```bash\nnpm install @ambiere/to-object\n```\n\n## Use case\n\nIn configuration files when import specifier string/path to the configuration module\ncan only be constructed dynamically, hence static imports become impractical, `require`\nnot supported in esmodule environment and dynamic imports, `import()` are not feasible\ndue to their asynchronous nature.\n\n```js\nconst configs = {\n  config1: \"first\",\n  config2: \"second\",\n  //other configs\n}\n```\n\n```js\nimport toObject from \"@ambiere/to-object\"\n\nfunction configure() {\n  // ...\n\n  /*\n  * In your code where\n  * you need to import the configs\n  * */\n\n  const configs = fs.readFileSync(\"/dynamically/constructed/import/specifier\", \"utf8\")\n  const parsedConfigs = toObject(configs)\n\n  console.log(parsedConfigs.config1) // \"first\"\n\n  // ...\n}\n```\n\nNote: The content of the configuration module/file to be read,\nshould be a valid JavaScript object\n\n## License\n\n[MIT license][MIT]\n\n[MIT]: https://github.com/ambiere/project-root/blob/main/license\n","readmeFilename":"readme.md"}