I suppose it can depend on how complicated is your yaml. For simply cases you can use this lib https://code.google.com/archive/p/javascript-yaml-parser/downloads
Just download and unpack the latest .gz file and copy contents of the file yaml.js into your project:

Then you can convert your yaml string into a json object this way:
// your YAML sting
var string =
`foo: bar
stuff:
foo: bar
bar: foo
arr:
- aaa
- bbb
- ccc
`
// JSON object
var obj = YAML.eval(string);
console.log(JSON.stringify(obj))
Output:
{
"foo": "bar",
"stuff": {
"foo": "bar",
"bar": "foo"
},
"arr": ["aaa", "bbb", "ccc"]
}