Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/pages/tinyaml/numbers/comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ description: Schema, merge keys, tags, documents, errors, dependencies and size,
| Anchors and aliases | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Multiple documents | ✅ `parseAll` | ✅ `loadAll` | ✅ `loadAll` | ✅ `parseAllDocuments` | ❌ merged into one | ✅ `parseAll` |
| Error line and column | ✅ 1-based | ✅ 0-based `mark` | ✅ 0-based `mark` | ✅ `linePos` | partial, line only | ✅ |
| Keeps comments | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
| Document, AST and CST | ❌ values only | ❌ | ❌ | ✅ `parseDocument` | ❌ | ❌ |
Comment thread
vite-hub[bot] marked this conversation as resolved.
Resolved
| Edits keep formatting | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
| Dependencies | 0 | 1, argparse | 1, argparse | 0 | 2, argparse and glob | 0 |
| ESM | ✅ ESM only | ✅ and CommonJS | ✅ and CommonJS | ✅ and CommonJS | ❌ CommonJS only | ✅ ESM only |
| TypeScript types | ✅ built in | `@types/js-yaml` | ✅ built in | ✅ built in | `@types/yamljs` | ✅ built in |
Expand All @@ -20,3 +23,7 @@ description: Schema, merge keys, tags, documents, errors, dependencies and size,
| Size, gzip | 7.8 KiB | 14.4 KiB | 17.1 KiB | 29.9 KiB | 8.8 KiB | 11.3 KiB |

The schema, merge, tag, document and error rows come from parsing the same inputs with each library's default options. A cell that names an option, like `mergeTag` or `merge: true`, needs that option. The others are defaults. The suite row is the first column of the [correctness table](/tinyaml/numbers/correctness/), which leaves out cases refused for an unknown tag and, for yamljs, streams without exactly one document. yaml's size is `parse` and `stringify` only, and js-yaml 5's is `load`, `loadAll`, `dump`, `Schema` and `YAMLException`.

## When to use yaml instead

tinyaml turns YAML into plain values and back, and never builds a syntax tree. That is most of why it's small and fast. If you need comments, the position of each node in the source, or to change a file and write it back with its formatting intact, use [yaml](https://eemeli.org/yaml/). It keeps all of that, and tinyaml doesn't try to.
2 changes: 2 additions & 0 deletions packages/tinyaml/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

**YAML for JavaScript in 7.8 KiB.** No dependencies, 12–19× faster than yaml 2, and right on all 373 [yaml-test-suite](https://github.com/yaml/yaml-test-suite) cases with an expected result: every valid document read, every invalid one rejected. js-yaml 4, yamljs and @std/yaml each get some wrong, and yaml 2.9.1 differs on 5, 2 of them by choice.

tinyaml reads and writes plain data. For comments, a syntax tree or editing files in place, use [yaml](https://eemeli.org/yaml/).

Already on another YAML library? Change one import and keep your code:

```diff
Expand Down
Loading