Closed DasdWaller closed 3 years ago
That will be very easy to do that:
import parse, { Options } from 'node-html-parser';
function createYourParseFun(optoins: Options){
return (html: string) =>{
return parse(html, options);
};
}
var yourparsefun = createYourParseFun(options);
var html1 = yourparsefun(html1);
var html2 = yourparsefun(html2);
var html3 = yourparsefun(html3);
var html4 = yourparsefun(html4);
var html5 = yourparsefun(html5);
var html6 = yourparsefun(html6);
or you can make this a class
import parse, { Options } from 'node-html-parser';
class YourParser {
constructor(private options: Options) { }
public parse(html: string) {
return parse(html, this.options);
}
}
var parser = new YourParser(options);
var html1 = parser.parse(html1);
var html2 = parser.parse(html2);
var html3 = parser.parse(html3);
var html4 = parser.parse(html4);
var html5 = parser.parse(html5);
var html6 = parser.parse(html6);
Both way will work.
Note I just export a parse function that is without state. This is very simple: you parsed params in, the function give you the result, no matter how many times.
Wish you good luck, and, if you have any idea about this, please let me know.
closing as no response.
Thanks for the package is very helpful for me. I try to parse some html but html is separate.
I expect something like: