There is—unfortunately—nothing in the standard library in JavaScript that will do this for you.
It's possible to build your own, but it's a lot of work. You would have to build a parser and there are likely a lot of edge cases that you would have to solve for. It might be worth considering using a third-party module.