{"_id":"@pnpm/yaml.document-sync","_rev":"5-02eef41b2f078653fa9037682a75cd8d","name":"@pnpm/yaml.document-sync","dist-tags":{"latest":"1100.0.2"},"versions":{"1000.0.0-0":{"name":"@pnpm/yaml.document-sync","version":"1000.0.0-0","keywords":["pnpm","pnpm11","patch","yaml"],"license":"MIT","_id":"@pnpm/yaml.document-sync@1000.0.0-0","maintainers":[{"name":"pnpmuser","email":"publish-bot@pnpm.io"},{"name":"zkochan","email":"z@kochan.io"}],"homepage":"https://github.com/pnpm/pnpm/tree/main/yaml/document-sync#readme","bugs":{"url":"https://github.com/pnpm/pnpm/issues"},"dist":{"shasum":"f80214c2fbe71ddbc3a4d436e3f9d77cda3934a0","tarball":"https://registry.npmjs.org/@pnpm/yaml.document-sync/-/yaml.document-sync-1000.0.0-0.tgz","fileCount":9,"integrity":"sha512-HlCvGfRoLckGoJxOeHBDdEBapj4iNhC+BA8CzxTMvjAZIgGXeSdWPB919miJiLqwNhK9zRktcbxqj83p/RLJ0w==","signatures":[{"sig":"MEUCIFEKLqG68a86/kMmiOOHxTDnyZFMQ++zTJ0SNRd9coxMAiEA1bHqQdqPLwfpTejoK6Ub8jPeFMKQgILTY9JQXMm8buw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20387},"jest":{"preset":"@pnpm/jest-config"},"main":"lib/index.js","type":"module","_from":"file:pnpm-yaml.document-sync-1000.0.0-0.tgz","types":"lib/index.d.ts","engines":{"node":">=20.19"},"exports":{".":"./lib/index.js"},"funding":"https://opencollective.com/pnpm","scripts":{"lint":"eslint \"src/**/*.ts\" \"test/**/*.ts\"","test":"pnpm run compile && pnpm run _test","_test":"cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest","compile":"tsc --build && pnpm run lint --fix"},"_npmUser":{"name":"pnpmuser","email":"publish-bot@pnpm.io"},"_resolved":"/tmp/1637328d63df94c5134494b69c8b0933/pnpm-yaml.document-sync-1000.0.0-0.tgz","_integrity":"sha512-HlCvGfRoLckGoJxOeHBDdEBapj4iNhC+BA8CzxTMvjAZIgGXeSdWPB919miJiLqwNhK9zRktcbxqj83p/RLJ0w==","repository":{"url":"git+https://github.com/pnpm/pnpm.git#main","type":"git"},"_npmVersion":"11.6.2","description":"Update a YAML document to match the contents of an in-memory object.","directories":{},"_nodeVersion":"24.11.1","dependencies":{"yaml":"^2.8.1"},"_hasShrinkwrap":false,"devDependencies":{"@pnpm/yaml.document-sync":"1000.0.0-0"},"_npmOperationalInternal":{"tmp":"tmp/yaml.document-sync_1000.0.0-0_1768316861167_0.6338654530771011","host":"s3://npm-registry-packages-npm-production"}},"1000.0.0":{"name":"@pnpm/yaml.document-sync","version":"1000.0.0","keywords":["pnpm","pnpm10","patch","yaml"],"license":"MIT","_id":"@pnpm/yaml.document-sync@1000.0.0","maintainers":[{"name":"pnpmuser","email":"publish-bot@pnpm.io"},{"name":"zkochan","email":"z@kochan.io"}],"homepage":"https://github.com/pnpm/pnpm/tree/main/yaml/document-sync#readme","bugs":{"url":"https://github.com/pnpm/pnpm/issues"},"dist":{"shasum":"417bd4e32fe8805868f500f9a9019b4f3c551256","tarball":"https://registry.npmjs.org/@pnpm/yaml.document-sync/-/yaml.document-sync-1000.0.0.tgz","fileCount":9,"integrity":"sha512-aEmCtfPJejq9I/q7pIYNo3Q0ryPrUoR57noCJbU+f0zNmg8JKG5YVVfCVvo5KNnG3LlN/MDyWvSHTeqy+HCoWA==","signatures":[{"sig":"MEYCIQCty/qg0y0sqS1Lk71usIiyxgkOqVpxUJXBJpRnOeTMIAIhANqJh7fy8Ilvy+FEKJXZWHNrlIkSfrBrdyiRIz5io+GF","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20928},"jest":{"preset":"@pnpm/jest-config"},"main":"lib/index.js","type":"commonjs","_from":"file:pnpm-yaml.document-sync-1000.0.0.tgz","types":"lib/index.d.ts","engines":{"node":">=18.12"},"exports":{".":"./lib/index.js"},"funding":"https://opencollective.com/pnpm","scripts":{"lint":"eslint \"src/**/*.ts\" \"test/**/*.ts\"","test":"pnpm run compile && pnpm run _test","_test":"jest","compile":"tsc --build && pnpm run lint --fix"},"_npmUser":{"name":"pnpmuser","email":"publish-bot@pnpm.io"},"_resolved":"/tmp/afe49c1cc872894919701f365d5e5ce9/pnpm-yaml.document-sync-1000.0.0.tgz","_integrity":"sha512-aEmCtfPJejq9I/q7pIYNo3Q0ryPrUoR57noCJbU+f0zNmg8JKG5YVVfCVvo5KNnG3LlN/MDyWvSHTeqy+HCoWA==","repository":{"url":"git+https://github.com/pnpm/pnpm.git#main","type":"git"},"_npmVersion":"11.6.2","description":"Update a YAML document to match the contents of an in-memory object.","directories":{},"_nodeVersion":"20.20.0","dependencies":{"yaml":"^2.8.1"},"_hasShrinkwrap":false,"devDependencies":{"@pnpm/yaml.document-sync":"1000.0.0"},"_npmOperationalInternal":{"tmp":"tmp/yaml.document-sync_1000.0.0_1772926488210_0.19093652219049817","host":"s3://npm-registry-packages-npm-production"}},"1100.0.0":{"name":"@pnpm/yaml.document-sync","version":"1100.0.0","keywords":["pnpm","pnpm11","patch","yaml"],"license":"MIT","_id":"@pnpm/yaml.document-sync@1100.0.0","maintainers":[{"name":"pnpmuser","email":"publish-bot@pnpm.io"},{"name":"zkochan","email":"z@kochan.io"}],"homepage":"https://github.com/pnpm/pnpm/tree/main/yaml/document-sync#readme","bugs":{"url":"https://github.com/pnpm/pnpm/issues"},"dist":{"shasum":"a4b3f6171c553605582993f3e7d2c86757df40e9","tarball":"https://registry.npmjs.org/@pnpm/yaml.document-sync/-/yaml.document-sync-1100.0.0.tgz","fileCount":7,"integrity":"sha512-pT+pFPM9r7bFVNbY4OU31H5vDYOzGrLgSVFfPexwo7aOZe8Tt5FELkiegAUIECrfL1oyRd0rGNZy4zagHuWSdg==","signatures":[{"sig":"MEQCIBdHEjlD6qiBB3UMX+uf6Tjvm2aHapva8E9FoNuqn0oGAiBpFJ/yGLgPr5zqvcKb/MJSMuFEzbVzZP3REM1pkMOA5Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@pnpm%2fyaml.document-sync@1100.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":13899},"jest":{"preset":"@pnpm/jest-config"},"main":"lib/index.js","type":"module","types":"lib/index.d.ts","engines":{"node":">=22.13"},"exports":{".":"./lib/index.js"},"funding":"https://opencollective.com/pnpm","scripts":{"lint":"eslint \"src/**/*.ts\" \"test/**/*.ts\"","test":"pn compile && pn .test",".test":"cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest","compile":"tsgo --build && pn lint --fix"},"_npmUser":{"name":"pnpmuser","email":"publish-bot@pnpm.io"},"repository":"https://github.com/pnpm/pnpm/tree/main/yaml/document-sync","description":"Update a YAML document to match the contents of an in-memory object.","directories":{},"_nodeVersion":"25.6.1","dependencies":{"yaml":"^2.8.3"},"_hasShrinkwrap":false,"devDependencies":{"@pnpm/yaml.document-sync":"1100.0.0"},"_npmOperationalInternal":{"tmp":"tmp/yaml.document-sync_1100.0.0_1775839243346_0.770202179399208","host":"s3://npm-registry-packages-npm-production"}},"1100.0.1":{"name":"@pnpm/yaml.document-sync","version":"1100.0.1","keywords":["pnpm","pnpm11","patch","yaml"],"license":"MIT","_id":"@pnpm/yaml.document-sync@1100.0.1","maintainers":[{"name":"pnpmuser","email":"publish-bot@pnpm.io"},{"name":"zkochan","email":"z@kochan.io"}],"homepage":"https://github.com/pnpm/pnpm/tree/main/pnpm11/yaml/document-sync#readme","bugs":{"url":"https://github.com/pnpm/pnpm/issues"},"dist":{"shasum":"9a5556a00fccf6bee555ac1cf55ecb437224446a","tarball":"https://registry.npmjs.org/@pnpm/yaml.document-sync/-/yaml.document-sync-1100.0.1.tgz","fileCount":8,"integrity":"sha512-1zs3MBnqsfYrcGa1ZhC2TNLdBb1p5RUAcuKF4BGLIolqe0GoJhhex0vEfaE3UezUoqyNbf0TDId/gfOBqA402g==","signatures":[{"sig":"MEUCIHOn+rXBioStoOSayI6MTE5oFJvDMPJHxovwpSaHjOzjAiEAu8pX/WIY2bBh4LgfJqdKLEDWGdqXlBcLBqF94ovuphE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@pnpm%2fyaml.document-sync@1100.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":14240},"jest":{"preset":"@pnpm/jest-config"},"main":"lib/index.js","type":"module","types":"lib/index.d.ts","engines":{"node":">=22.13"},"exports":{".":"./lib/index.js"},"funding":"https://opencollective.com/pnpm","scripts":{"lint":"eslint \"src/**/*.ts\" \"test/**/*.ts\"","test":"pn compile && pn .test",".test":"cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest","compile":"tsgo --build && pn lint --fix"},"_npmUser":{"name":"pnpmuser","email":"publish-bot@pnpm.io"},"repository":{"url":"https://github.com/pnpm/pnpm/tree/main/pnpm11/yaml/document-sync","type":"git"},"description":"Update a YAML document to match the contents of an in-memory object.","directories":{},"dependencies":{"yaml":"^2.9.0"},"_hasShrinkwrap":false,"devDependencies":{"@jest/globals":"30.4.1","@pnpm/yaml.document-sync":"1100.0.1"},"_npmOperationalInternal":{"tmp":"tmp/yaml.document-sync_1100.0.1_1784825084282_0.27742032670719974","host":"s3://npm-registry-packages-npm-production"}},"1100.0.2":{"_id":"@pnpm/yaml.document-sync@1100.0.2","bugs":{"url":"https://github.com/pnpm/pnpm/issues"},"dist":{"shasum":"8d8e8a44f6118d2edbcd8a30d0a8196c0f339029","tarball":"https://registry.npmjs.org/@pnpm/yaml.document-sync/-/yaml.document-sync-1100.0.2.tgz","fileCount":10,"integrity":"sha512-DXohTVqVxIDf30cPlBczibqDnSzsAB1N9PPBMGf7EkBgiOaJNvsWkFA6QeI90XVMAkLCRjV4S6LdnhVpB8U80w==","signatures":[{"sig":"MEUCIQCFjtASsfwzvfGqaZL+cviRSFkkutTaJUcPsX5dsWL3eQIgCTuiXpZ0e0yhHifdWTizQNR2jL2jSKvHQ3NlZrSGhkw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDkWeQy7pbTMzd1qUcZGVO0FzeCZ5zghXoELDGm2zlYrAiA0OBeBKImognwfuiSYHseEel3HU54qqizdojKeXxyo/A=="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@pnpm%2fyaml.document-sync@1100.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":20078},"jest":{"preset":"@pnpm/jest-config"},"main":"lib/index.js","name":"@pnpm/yaml.document-sync","type":"module","types":"lib/index.d.ts","engines":{"node":">=22.13"},"exports":{".":"./lib/index.js"},"funding":"https://opencollective.com/pnpm","license":"MIT","scripts":{"lint":"eslint \"src/**/*.ts\" \"test/**/*.ts\"","test":"pn compile && pn .test",".test":"cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest","compile":"tsgo --build && pn lint --fix"},"version":"1100.0.2","_npmUser":{"name":"pnpmuser","email":"publish-bot@pnpm.io"},"homepage":"https://github.com/pnpm/pnpm/tree/main/pnpm11/yaml/document-sync#readme","keywords":["pnpm","pnpm11","patch","yaml"],"repository":{"url":"https://github.com/pnpm/pnpm/tree/main/pnpm11/yaml/document-sync","type":"git"},"description":"Update a YAML document to match the contents of an in-memory object.","directories":{},"maintainers":[{"name":"pnpmuser","email":"publish-bot@pnpm.io"},{"name":"zkochan","email":"z@kochan.io"}],"dependencies":{"yaml":"^2.9.1"},"_hasShrinkwrap":false,"devDependencies":{"@jest/globals":"30.4.1","@pnpm/yaml.document-sync":"1100.0.2"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/yaml.document-sync_1100.0.2_1789939493780_0.299760459874467"}}},"time":{"created":"2026-01-13T15:07:41.062Z","modified":"2026-09-20T21:24:54.181Z","1000.0.0-0":"2026-01-13T15:07:41.304Z","1000.0.0":"2026-03-07T23:34:48.363Z","1100.0.0":"2026-04-10T16:40:43.517Z","1100.0.1":"2026-07-23T16:44:44.469Z","1100.0.2":"2026-09-20T21:24:53.859Z"},"bugs":{"url":"https://github.com/pnpm/pnpm/issues"},"license":"MIT","homepage":"https://github.com/pnpm/pnpm/tree/main/pnpm11/yaml/document-sync#readme","keywords":["pnpm","pnpm11","patch","yaml"],"repository":{"url":"https://github.com/pnpm/pnpm/tree/main/pnpm11/yaml/document-sync","type":"git"},"description":"Update a YAML document to match the contents of an in-memory object.","maintainers":[{"name":"pnpmuser","email":"publish-bot@pnpm.io"},{"name":"zkochan","email":"z@kochan.io"}],"readme":"# @pnpm/yaml.document-sync\n\n> Update a YAML document to match the contents of an in-memory object.\n\n<!--@shields('npm')-->\n[![npm version](https://img.shields.io/npm/v/@pnpm/yaml.document-sync.svg)](https://npmx.dev/package/@pnpm/yaml.document-sync)\n<!--/@-->\n\n## Installation\n\n```sh\npnpm add @pnpm/yaml.document-sync\n```\n\n## Usage\n\nGiven a \"_source_\" document such as:\n\n```yaml\nfoo:\n  bar:\n    # 25 is better than 24\n    baz: 25\n\nqux:\n  # He was number 1\n  - 1\n```\n\nAnd a \"_target_\" object in-memory:\n\n```ts\nimport fs from 'node:fs'\nimport { patchDocument } from '@pnpm/yaml.document-sync'\nimport yaml from 'yaml'\n\nconst source = await fs.promises.readFile('source.yaml', 'utf8')\nconst document = yaml.parseDocument(source)\n\nconst target = {\n  foo: { bar: { baz: 25 } },\n  qux: [1, 2, 3]\n}\n\npatchDocument(document, target)\n```\n\nThe `patchDocument` function will mutate `document` to match the `target`'s contents, retaining comments along the way. In the example above, the final rendered document will be:\n\n```yaml\nfoo:\n  bar:\n    # 25 is better than 24\n    baz: 25\n\nqux:\n  # He was number 1\n  - 1\n  - 2\n  - 3\n```\n\nFor package manifests, retain null values and empty maps and keep existing keys in their original order:\n\n```ts\npatchDocument(document, target, {\n  preserveKeyOrder: true,\n  preserveScalarAliases: true,\n  pruneEmptyValues: false,\n})\n```\n\nNew keys are appended to their mapping. By default, keys follow the target object's order, and null values and empty maps are pruned from existing nodes.\n\nConsumers that use a different conversion for scalar mapping keys can pass `stringifyKey`. For example, `stringifyKey: String` matches `js-yaml`, which exposes a null mapping key as the property name `\"null\"`. The default follows `yaml` and uses an empty string.\n\n## Purpose\n\nThis package is useful when your codebase:\n\n1. Uses the [yaml](https://npmx.dev/package/yaml) library.\n2. Calls `.toJSON()` on the parse result and performs changes to it.\n3. Needs to \"sync\" those changes back to the source document.\n\nInstead of this package, consider performing mutations directly on the `yaml.Document` returned from `yaml.parseDocument()` instead. Directly modifying will be faster and more accurate. This package exists as a workaround for codebases that make changes to a JSON object instead and need to reconcile changes back into the source `yaml.Document`.\n\n## Caveats\n\nThere are several cases where comment preservation is inherently ambiguous. If the caveats outlined below are problematic, consider modifying the source `yaml.Document` before running the patch function in this package.\n\n### Key Renames\n\nFor example, renames of a key are ambiguous. Given:\n\n```yaml\n- foo:\n    # Test\n    bar: 1\n```\n\nAnd a target object to match:\n\n```json\n{\n  \"baz\": {\n    \"bar\": 1\n  }\n}\n```\n\nThe comment on `bar` won't be retained.\n\n### List Reconciliation\n\nFor simple lists (e.g. lists with only primitives), items will be uniquely matched using their contents. However, updates to complex lists are inherently ambiguous.\n\nFor example, given a source list with objects as elements:\n\n```yaml\n- foo: 1\n# Comment\n- bar: 2\n```\n\nAnd a target:\n\n```json\n[\n  { \"foo\": 1 },\n  { \"baz\": 3 },\n  { \"bar\": 2 }\n]\n```\n\nThe result will erase the comment:\n\n```yaml\n- foo: 1\n- baz: 3\n- bar: 2\n```\n\nIt's not trivial to detect that the object with `bar` as a field moved down. Detecting this case would require a diffing algorithm, which would be best effort anyway.\n\nVirtual DOM libraries such as React have the same problem. In React, list elements need to specify a `key` prop to uniquely identify each item. This library may take a similar approach in the future if needed. This is not a problem for primitive lists since their values can be compared using simple equality checks.\n\n### Aliases\n\nGiven:\n\n```yaml\nfoo: &config\n  - 1\n  - 2\n\nbar: *config\n```\n\nAnd a target object:\n\n```json\n{\n  \"foo\": [1, 2],\n  \"bar\": [1, 2, 3]\n}\n```\n\nFor correctness, the YAML alias needs to be removed.\n\n```yaml\nfoo: &config\n  - 1\n  - 2\n\nbar:\n  - 1\n  - 2\n  - 3\n```\n\nSet `preserveScalarAliases: true` to retain scalar aliases whose final values\nagree. If an anchor's defining entry is removed, the first surviving entry\ndefines it. An entry whose value differs from the defining entry is written\nas a scalar. This option does not coordinate dependency updates; it preserves\nYAML representation while applying the supplied target values.\n\n```ts\npatchDocument(document, target, { preserveScalarAliases: true })\n```\n\n## License\n\nMIT\n","readmeFilename":""}