@stoplight/yaml
Useful functions when working with YAML.
Installation
Supported in modern browsers and node.
yarn add @stoplight/yaml
Usage
import { parseWithPointers } from "@stoplight/yaml";
const result = parseWithPointers("foo: bar");
console.log(result.data);
import { getJsonPathForPosition, getLocationForJsonPath, parseWithPointers } from "@stoplight/yaml";
const result = parseWithPointers(`hello: world
address:
street: 123`
);
const path = getJsonPathForPosition(result, { line: 2, character: 7 });
console.log(path);
const position = getLocationForJsonPath(result, ['address']);
console.log(position.range.start);
console.log(position.range.end);
Contributing
- Clone repo.
- Create / checkout
feature/{name}
, chore/{name}
, or fix/{name}
branch. - Install deps:
yarn
. - Make your changes.
- Run tests:
yarn test.prod
. - Stage relevant files to git.
- Commit:
yarn commit
. NOTE: Commits that don't follow the conventional format will be rejected. yarn commit
creates this format for you, or you can put it together manually and then do a regular git commit
. - Push:
git push
. - Open PR targeting the
next
branch.