-
Notifications
You must be signed in to change notification settings - Fork 151
Description
Is your feature request related to a problem? Please describe.
I have a situation where I have a list of paths from a YAML document. I need to map these paths to the location in the document source code. This can be done using the following code:
import { parseDocument } from 'yaml';
const yaml = `
foo: &anchor
bar: 1
fooz:
baz: *anchor
`;
const doc = parseDocument(yaml, {});
console.dir(doc.getIn(['foo', 'bar'], true));
console.dir(doc.getIn(['fooz', 'baz'], true));
console.dir(doc.getIn(['fooz', 'baz', 'bar'], true));Unfortunately the last statement doesn’t work, because getIn doesn’t resolve aliases.
Describe the solution you'd like
I would love for getIn to be able to resolve aliases.
Describe alternatives you've considered
Possibly new methods can be introduced: resolve(key, keepScalar?) and resolveIn(path, keepScalar?). This would avoid breaking changes in get and getIn respectively.
It’s possible to do this manually, but I think it’s a useful feature for this library to support out of the box.
Additional context
We use this together with the jsonschema package. Apart from this issue, it’s working amazing!