Dompurify and jsdom module help?

Anybody explain me what is the use of dompurify and jsdom module.

jsdom is an implementation of the HTML DOM in JavaScript. Code run on Node knows nothing about the DOM or HTML. Most JS testing uses Node because it would be extremely slow to have to open up a browser for every test that runs. So if a test needs to be run against the DOM (for example, test if a button click runs the function you’ve programmed it to), you can use jsdom.

Completely different subject: if you have some UI where users can input raw HTML and that input gets processed into your application (examples: comment sections/forums where users can mark up their posts using HTML), that’s an attack vector. You can sanitise that input to prevent XSS attacks, dompurify is a library that does this. Give it a string of HTML markup, it will sanitise it. See the example: