Hi!
( Your YAML lib is awesome and the only one to provide AST out there! So first: Thank you ! )
I am cooking a plugin to the library to be able to add a custom alias resolution function in case the alias is missing its corresponding anchored node.
It work well in general, but it relies on puting the missing nodes (usually generated) in ctx.anchors for later resolution to use cached values...
I wonder why the merge key part do not use/propagate the ctx while resolving alias for merge keys?
Here:
|
value = ctx && isAlias(value) ? value.resolve(ctx.doc) : value |
and here:
|
const source = ctx && isAlias(value) ? value.resolve(ctx.doc) : value |
Those should be
value.resolve(ctx.doc, ctx)
, doesn't they?
Is there a particular reason (I'm missing) why those resolution does not use the context ?
Thx
PS: My plugin would mainly be used to parse file path from missing alias and load the file for it to be included inplace (maybe targeting data with JSONPath). While I could not use ctx.anchor, the cached strategy would be more efficient in case big files are loaded and used several times...
Example: this loads & parse 2 times the same common.yaml file
config:
<<: *./configs/common.yaml
foo: bar override
database:
<<: *./configs/common.yaml
While this example does not (because of ctx)
config: *./configs/common.yaml
database: *./configs/common.yaml
but lacks of a way to override/add pairs to the map...
Hi!
I am cooking a plugin to the library to be able to add a custom alias resolution function in case the alias is missing its corresponding anchored node.
It work well in general, but it relies on puting the missing nodes (usually generated) in
ctx.anchorsfor later resolution to use cached values...I wonder why the merge key part do not use/propagate the
ctxwhile resolving alias for merge keys?Here:
yaml/src/schema/yaml-1.1/merge.ts
Line 46 in 6a6f8fb
and here:
yaml/src/schema/yaml-1.1/merge.ts
Line 58 in 6a6f8fb
Those should be
, doesn't they?
Is there a particular reason (I'm missing) why those resolution does not use the context ?
Thx
PS: My plugin would mainly be used to parse file path from missing alias and load the file for it to be included inplace (maybe targeting data with JSONPath). While I could not use
ctx.anchor, the cached strategy would be more efficient in case big files are loaded and used several times...Example: this loads & parse 2 times the same common.yaml file
While this example does not (because of
ctx)but lacks of a way to override/add pairs to the map...