Repository navigation
Conversation
Contributor
|
tested this against yaml, throws on a bad doc and returns [] for empty input. lgtm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Linked issue
Related to #840. This corrects the multi-document migration example; the broader performance and compliance comparison remains open.
📚 Description
Implementation assisted by AI tools.
The multi-document example converts documents even when
yamlreports parsing errors. For example,---\na: 1\na: 2\nmakesjs-yaml.loadAllthrow, but the documented replacement silently returns{a: 2}.Check errors on an empty stream and on each document before calling
toJSON(), so the example throws the first reported parsing error. This also handles malformed directives that produce no documents.Validation
pnpm build,pnpm lint, changed-file Prettier, andgit diff --checkpassed with Node 20.20.2 and pnpm 10.33.3. The corrected snippet also passed a strict standalone TypeScript check.yaml@2.9.1againstjs-yaml@4.1.1andjs-yaml@5.4.2: 10 cases passed per version. The previous example silently accepted six malformed inputs; the corrected example rejects all six. Valid and empty inputs retain the replacement's previous results.65ab92aagainst basef7f91a9. These results cover that tested revision; this PR's checks run separately.Reviewed with the help of AI.