@ooneex/yml reads YAML files lazily through an async generator instead of loading the whole file into memory. It handles both multi-document files (--- separators) and top-level array files (- items), supports per-field ignore filters, and can export the parsed stream straight to JSON or CSV. It is built on Bun’s native YAML support, so it runs in the Bun runtime.
Installation
Add the package with Bun.Usage
Create aYaml instance pointing at a file, then iterate its load() generator. Each yielded value is one document (or one array item) from the file.
ignore map to skip items whose field matches a RegExp. Matched items are dropped from the stream.
toJson, or to a CSV with toCsv (you choose the columns and separator). Both reuse the same lazy reader, so they never hold the full dataset in memory.
YamlException carrying a key (FILE_NOT_FOUND, READ_FAILED, or PARSE_FAILED) and the offending path.
When to use it
- You need to process large YAML datasets (logs, seed data, exports) without loading the entire file into memory.
- Your file is a stream of documents separated by
---, or a top-level list of-items, and you want each entry one at a time. - You want to convert YAML to JSON or CSV as a streamed pipeline, optionally filtering out rows by a field pattern.
- You need typed iteration with a small, Bun-native dependency footprint.
- You don’t need it for small config files you load once — Bun’s
YAML.parse(or a plain import) is simpler when the whole file fits comfortably in memory.