js-yaml
js-yaml copied to clipboard
Feature Request: Pass filename to custom type construct callback
It would be very useful if construct callback of a custom type also receives filename as third parameter, for example:
const jsSchema = new yaml.Type("!js", {
resolve: (data) => data != undefined && data!=null,
construct: (data, tag, filename) => {
...
},
represent: (content) => content.toString()
});
The following line seems to be the place to make the change (pass state.filename as third argument to type.construct):
https://github.com/nodeca/js-yaml/blob/49baadd52af887d2991e2c39a6639baa56d6c71b/lib/loader.js#L1531
Please let me know If that's an acceptable change request. If so, I'll be more than happy to send a PR.
Cheers!