4.3.0 • Published 10 months ago
@stoplight/yaml v4.3.0
@stoplight/yaml
Useful functions when working with YAML.
Installation
Supported in modern browsers and node.
# latest stable
yarn add @stoplight/yaml
Usage
- getJsonPathForPosition: Computes JSON path for given position.
- getLocationForJsonPath: Retrieves location of node matching given JSON path.
- parseWithPointers: Parses YAML into JSON and also returns diagnostics as well as full ast with line information.
// basic example of parseWithPointers
import { parseWithPointers } from "@stoplight/yaml";
const result = parseWithPointers("foo: bar");
console.log(result.data); // => the {foo: "bar"} JS object
// basic example of getJsonPathForPosition and getLocationForJsonPath
import { getJsonPathForPosition, getLocationForJsonPath, parseWithPointers } from "@stoplight/yaml";
const result = parseWithPointers(`hello: world
address:
street: 123`
);
const path = getJsonPathForPosition(result, { line: 2, character: 7 }); // line and character are 0-based
console.log(path); // -> ["address", "street"];
const position = getLocationForJsonPath(result, ['address']);
console.log(position.range.start); // { line: 1, character: 8 } line and character are 0-based
console.log(position.range.end); // { line: 2, character: 15 } line and character are 0-based
Contributing
- Clone repo.
- Create / checkout
feature/{name}
,chore/{name}
, orfix/{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 regulargit commit
. - Push:
git push
. - Open PR targeting the
next
branch.
4.3.0
10 months ago
4.2.3
3 years ago
4.2.2
4 years ago
4.2.1
4 years ago
4.2.0
5 years ago
4.1.0
5 years ago
4.0.2
5 years ago
4.0.1
5 years ago
4.0.0
5 years ago
3.8.1
5 years ago
3.8.0
5 years ago
3.7.1
5 years ago
3.7.0
5 years ago
3.6.0
5 years ago
3.5.2
5 years ago
3.5.1
5 years ago
3.5.0
5 years ago
3.4.0
5 years ago
3.3.2
5 years ago
3.3.1
5 years ago
3.3.0
5 years ago
3.2.0
5 years ago
3.1.1
5 years ago
3.1.0
5 years ago
3.0.2
5 years ago
3.0.1
5 years ago
3.0.0
5 years ago
2.8.0
5 years ago
2.7.0
5 years ago
2.6.1
5 years ago
2.6.0
5 years ago
2.5.1
6 years ago
2.5.0
6 years ago
2.4.0
6 years ago
2.3.0
6 years ago
2.2.1
6 years ago
2.2.0
6 years ago
2.1.2
6 years ago
2.1.1
6 years ago
2.1.0
6 years ago
2.0.0
6 years ago
1.2.1
6 years ago
1.2.0
6 years ago
1.1.0
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago