Closed
Description
const yaml = require("js-yaml")
class Test {
constructor(id) {
this.id = id
}
id
get Id() {
return this.id
}
async fetchData() {
console.log("get async data")
}
}
var customtagYamlType = new yaml.Type("!mapInfo", {
kind: "scalar",
resolve: () => true,
construct: (id) => new Test(id),
instanceOf: Test,
represent: (customTag) => customTag.id,
})
const obj = {
name: 'some',
data:{
content:[
{
value: new Test("1")
}
]
}
}
const schema = yaml.Schema.create([customtagYamlType])
const result = yaml.dump(obj, { schema })
console.log(result)
/* the output is
data:
content:
- value: !<!mapInfo> '1'
-----------------------------------------
i am expecting like in the documentation
data:
content:
- value: !mapInfo '1'
node version v12.14.1
*/
Metadata
Metadata
Assignees
Labels
No labels