{"name":"@prettier/sync","version":"0.6.1","description":"Synchronous version of Prettier","homepage":"https://github.com/prettier/prettier-synchronized#readme","bugs":{"url":"https://github.com/prettier/prettier-synchronized/issues"},"repository":{"type":"git","url":"git+https://github.com/prettier/prettier-synchronized.git"},"funding":"https://github.com/prettier/prettier-synchronized?sponsor=1","license":"MIT","author":{"name":"fisker Cheung","email":"lionkay@gmail.com","url":"https://www.fiskercheung.com/"},"sideEffects":false,"type":"module","main":"./index.cjs","exports":{".":{"types":{"import":"./index.d.mts","default":"./index.d.cts"},"default":"./index.cjs"},"./*":"./*"},"scripts":{"dist":"release-it","fix":"prettier . --write","lint":"prettier . --check","test":"node --test","test-coverage":"c8 node --test","release":"run-s lint test dist"},"c8":{"reporter":["lcov","text"]},"peerDependencies":{"prettier":"*"},"devDependencies":{"@types/node":"22.15.30","c8":"10.1.3","npm-run-all":"4.1.5","prettier":"3.5.3","release-it":"19.0.3"},"packageManager":"yarn@4.9.2","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"dependencies":{"make-synchronized":"^0.8.0"},"gitHead":"a3872fd3618c4f88a1473638e6096a65f6cdf91e","_id":"@prettier/sync@0.6.1","_nodeVersion":"22.14.0","_npmVersion":"9.1.2","dist":{"integrity":"sha512-yF9G8vK/LYUTF3Cijd7VC9La3b20F20/J/fgoR4H0B8JGOWnZVZX6+I6+vODPosjmMcpdlUV+gUqJQZp3kLOcw==","shasum":"d868fe826610b689acd79c5520f357c0e0be0eda","tarball":"http://registry-npm.ywwl.com/@prettier/sync/download/@prettier/sync-0.6.1.tgz","fileCount":6,"unpackedSize":7623,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHzgZrX7E8WHhahX82vlGSL1diFPBWb6LUm9Nilt6DAuAiAjPvzbfI0SrCWpsF9UXnpwmHMGPlwLYAdf0I1j5ubJ/A=="}],"size":2854,"noattachment":false,"key":"/@prettier/sync/-/@prettier/sync-0.6.1.tgz"},"_npmUser":{"name":"fisker","email":"lionkay@gmail.com"},"directories":{},"maintainers":[{"name":"suchipi","email":"me@suchipi.com"},{"name":"mgrip","email":"necktie_airfoil.0m@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"},{"name":"fisker","email":"lionkay@gmail.com"},{"name":"sosukesuzuki","email":"aosukeke@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sync_0.6.1_1749393552473_0.69229559398025"},"_hasShrinkwrap":false,"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":1749393552656,"_cnpm_publish_time":1749393552656,"dist-tags":{"latest":"0.6.1"}}