{"name":"@prettier/sync","version":"0.3.0","author":{"url":"https://www.fiskercheung.com/","name":"fisker Cheung","email":"lionkay@gmail.com"},"license":"MIT","_id":"@prettier/sync@0.3.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":"91f2cfc23490a21586d1cf89c6f72157c000ca1e","tarball":"http://registry-npm.ywwl.com/@prettier/sync/download/@prettier/sync-0.3.0.tgz","fileCount":6,"integrity":"sha512-3dcmCyAxIcxy036h1I7MQU/uEEBq8oLwf1CE3xeze+MPlgkdlb/+w6rGR/1dhp6Hqi17fRS6nvwnOzkESxEkOw==","signatures":[{"sig":"MEUCIQDBnf+SdY2rlPzfhmkqS2K0EMfLLMWpjD15JRM+2WfD3wIgEYeX7oDJiI5FoxcThaIMtklyIvJgUFoLc2gWySuZQ68=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10478,"size":3725,"noattachment":false,"key":"/@prettier/sync/-/@prettier/sync-0.3.0.tgz"},"main":"./index.cjs","type":"module","exports":{".":{"types":"./index.d.cts","default":"./index.cjs"},"./*":"./*"},"funding":"https://github.com/prettier/prettier-synchronized?sponsor=1","gitHead":"f8f9cec17cb3c93cbd162653c2c24d74fd10321d","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":"8.0.0","prettier":"3.0.0","@types/node":"20.4.1","npm-run-all":"4.1.5"},"peerDependencies":{"prettier":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sync_0.3.0_1689595200536_0.7468928161334107","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":1689595200676,"_cnpm_publish_time":1689595200676,"dist-tags":{"latest":"0.6.1"}}