yaml-unist-parser
Version:
A YAML parser that produces output compatible with unist
68 lines (45 loc) • 1.2 kB
Markdown
[](https://www.npmjs.com/package/yaml-unist-parser)
[](https://codecov.io/gh/prettier/yaml-unist-parser)
A YAML parser that produces output compatible with [unist](https://github.com/syntax-tree/unist)
- better node positioning
- better comment attaching
- [unist-compatible AST](https://github.com/prettier/yaml-unist-parser/blob/main/src/types.ts)
```sh
npm install --save yaml-unist-parser
yarn add yaml-unist-parser
```
```ts
import { parse } from "yaml-unist-parser";
const ast = parse(`
- hello
- world
`);
```
type `boolean`\
default: `true`
Whether key uniqueness is checked.
```js
parse("a: 1\na: 2");
// Uncaught SyntaxError [YAMLSyntaxError]: Map keys must be unique
parse("a: 1\na: 2", { uniqueKeys: false });
// {type: 'root',...}
```
```sh
yarn run lint
yarn run build
yarn run test
```
MIT © [Ika](https://github.com/ikatyang)