{"name":"@prettier/sync","version":"0.2.0","author":{"url":"https://www.fiskercheung.com/","name":"fisker Cheung","email":"lionkay@gmail.com"},"license":"MIT","_id":"@prettier/sync@0.2.0","maintainers":[{"name":"fisker","email":"lionkay@gmail.com"},{"name":"suchipi","email":"me@suchipi.com"},{"name":"mgrip","email":"mike.grip@icloud.com"},{"name":"czosel","email":"christian@zosel.ch"},{"name":"patrick91","email":"patrick.arminio@gmail.com"},{"name":"zimme","email":"simon@fridlund.email"},{"name":"azz","email":"lucas@azzola.dev"},{"name":"vjeux","email":"vjeuxx@gmail.com"},{"name":"evilebottnawi","email":"sheo13666q@gmail.com"},{"name":"kddeisz","email":"kddnewton+npm@gmail.com"},{"name":"shinigami92","email":"chrissi92@hotmail.de"},{"name":"j-f","email":"git@jedfox.com"},{"name":"lydell","email":"simon.lydell@gmail.com"}],"homepage":"https://github.com/prettier/prettier-synchronized#readme","bugs":{"url":"https://github.com/prettier/prettier-synchronized/issues"},"c8":{"reporter":["lcov","text"]},"dist":{"shasum":"bd9fc8043d9731043e1525ed3e6f0451776cc2f3","tarball":"http://registry-npm.ywwl.com/@prettier/sync/download/@prettier/sync-0.2.0.tgz","fileCount":5,"integrity":"sha512-vAW4wwGaUI+LHeQxv8R3C1/4gnzA7VBTHGYSsybDY0tqv9MYlrUKlmN4fn2IztujABDMfMAV9YuDEki5uHiXRQ==","signatures":[{"sig":"MEUCIQD/NCdUDFpJ+1JCxPOS0iI5/sFtcqiYkRHHnNTcDKK+dwIgL1tG6qMHFHT4vPaG3G7+HYKDqMPNCxxRYDyL5qAh7rc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":7002,"size":2894,"noattachment":false,"key":"/@prettier/sync/-/@prettier/sync-0.2.0.tgz"},"type":"module","exports":"./index.cjs","funding":"https://github.com/prettier/prettier-synchronized?sponsor=1","gitHead":"481f8f7d2f3e8e32b60eb8e2ae2b450123af37e4","scripts":{"dist":"np --yolo --no-yarn","lint":"prettier . --check","test":"node --test","format":"prettier . --write","release":"run-s lint test dist","test-coverage":"c8 node --test"},"_npmUser":{"name":"fisker","email":"lionkay@gmail.com"},"repository":{"url":"git+https://github.com/prettier/prettier-synchronized.git","type":"git"},"_npmVersion":"9.1.2","description":"Synchronous version of Prettier","directories":{},"sideEffects":false,"_nodeVersion":"18.14.2","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"packageManager":"yarn@3.2.2","devDependencies":{"c8":"7.12.0","prettier":"3.0.0-alpha.0","npm-run-all":"4.1.5"},"peerDependencies":{"prettier":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sync_0.2.0_1688982599111_0.7716573109624825","host":"s3://npm-registry-packages"},"readme":"# @prettier/sync\n\n[![Build Status][github_actions_badge]][github_actions_link]\n[![Coverage][codecov_badge]][codecov_link]\n[![Npm Version][package_version_badge]][package_link]\n[![MIT License][license_badge]][license_link]\n\n[github_actions_badge]: https://img.shields.io/github/actions/workflow/status/prettier/prettier-synchronized/continuous-integration.yml?style=flat-square\n[github_actions_link]: https://github.com/prettier/prettier-synchronized/actions?query=branch%3Amain\n[codecov_badge]: https://img.shields.io/codecov/c/github/prettier/prettier-synchronized?style=flat-square\n[codecov_link]: https://codecov.io/gh/prettier/prettier-synchronized\n[license_badge]: https://img.shields.io/npm/l/@prettier/sync.svg?style=flat-square\n[license_link]: https://github.com/prettier/prettier-synchronized/blob/main/license\n[package_version_badge]: https://img.shields.io/npm/v/@prettier/sync.svg?style=flat-square\n[package_link]: https://www.npmjs.com/package/@prettier/sync\n\n> Synchronous version of Prettier\n\n## Installation\n\n```sh\nyarn add prettier @prettier/sync\n```\n\n## Usage\n\n```js\nimport synchronizedPrettier from \"@prettier/sync\";\n\nsynchronizedPrettier.format(\"foo( )\", { parser: \"babel\" });\n// => 'foo();\\n'\n```\n\nThis package is a simple wrapper of [`make-synchronized`](https://github.com/fisker/make-synchronized).\n\nFor more complex use cases, it's better to use [`make-synchronized`](https://github.com/fisker/make-synchronized) directly:\n\nExample 1:\n\n```js\n// utilities.js\nimport * as fs from \"node:fs/promises\";\nimport * as prettier from \"prettier\";\n\nexport async function formatFile(file) {\n  const config = await prettier.resolveConfig(file);\n  const content = await fs.readFile(file, \"utf8\");\n  const formatted = await prettier.format(content, {\n    ...config,\n    filepath: file,\n  });\n  await fs.writeFile(file, formatted);\n}\n\n// index.js\nimport makeSynchronized from \"make-synchronized\";\n\nconst utilities = makeSynchronized(new URL(\"./utilities.js\", import.meta.url));\n\nutilities.formatFile(\"/path/to/file.js\");\n```\n\nExample 2:\n\n```js\nimport * as fs from \"node:fs/promises\";\nimport * as prettier from \"prettier\";\nimport makeSynchronized from \"make-synchronized\";\n\nexport default makeSynchronized(import.meta, async function formatFile(file) {\n  const config = await prettier.resolveConfig(file);\n  const content = await fs.readFile(file, \"utf8\");\n  const formatted = await prettier.format(content, {\n    ...config,\n    filepath: file,\n  });\n  await fs.writeFile(file, formatted);\n});\n```\n\nAlternatively you can also use [`synckit`](https://github.com/un-ts/synckit) or [`make-synchronous`](https://github.com/sindresorhus/make-synchronous).\n\n### `createSynchronizedPrettier(options)`\n\n#### `options`\n\nType: `object`\n\n##### `prettierEntry`\n\nType: `string | URL`\n\nPath or URL to prettier entry.\n\n```js\nimport { createSynchronizedPrettier } from \"@prettier/sync\";\n\nconst synchronizedPrettier = createSynchronizedPrettier({\n  prettierEntry: \"/path/to/prettier/index.js\",\n});\n\nsynchronizedPrettier.format(\"foo( )\", { parser: \"babel\" });\n// => 'foo();\\n'\n```\n","publish_time":1688982599324,"_cnpm_publish_time":1688982599324,"dist-tags":{"latest":"0.6.1"}}