https://github.com/morganconrad/yaml-y
Small, limited, regex-based YAML parser
https://github.com/morganconrad/yaml-y
Last synced: over 1 year ago
JSON representation
Small, limited, regex-based YAML parser
- Host: GitHub
- URL: https://github.com/morganconrad/yaml-y
- Owner: MorganConrad
- License: mit
- Created: 2024-03-24T04:58:47.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-24T04:59:34.000Z (about 2 years ago)
- Last Synced: 2025-01-11T14:45:55.759Z (over 1 year ago)
- Language: JavaScript
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](http://travis-ci.org/MorganConrad/metalsmith-get-contentful)
[](https://github.com/MorganConrad/yaml-y)
[](https://snyk.io/test/github/morganconrad/yaml-y)
[](https://coveralls.io/github/MorganConrad/yaml-y)
# yaml-y
A tiny, _very partial implementation_ of a YAML parser. Mainly intended for my own use, such as when parsing markdown file metadata. If you want to parse complex YAML, use either
- [YAML](https://www.npmjs.com/package/yaml) (107KB)
- [js-yaml](https://www.npmjs.com/package/js-yaml) (139KB)
- [yaml-js](https://www.npmjs.com/package/yaml-js) (**Abandoned**, 117KB)
- or dont use YAML, it is arguably a poor choice for complex data.
See `test/testData.yaml` and `test/expected.json` for example inputs and outputs
yaml-y understands
- boolean (`true` and `false`)
- One dimensional arrays (not nested)
- quoted or naked strings
- there is no attempt to differentiate a number
- empty lines
- comment lines whose _first_ character is `#`
### Usage
```
import { parseYAML } from "yaml-y";
const yamlString = readFromAFile("myfile.yaml");
let object = parseYAML(yamlString, options);
```
### Options
None yet, maybe some will be added later?
### Notes, Todos, and Caveats
It may throw an `Error` on input it doesn't understand.