It works well in passing primary variables and arrays to a js function in an evaluate method. But it can't work with a map.
color_map = new Map();
color_map.set("red",100);
color_map.set("white",200);
color_map.set("blue",300);
page.evaluate(function(color_map){
for(const [key,value] of color_map.entries())
{
alert(value);
}
// alert(color_map);
},color_map);
Puppeteer throws an error:
Evaluation failed: TypeError: color_map.entries is not a function or its return value is not iterable
Does puppeteer provide any api to achieve this? If no, I only can unzip the map to key and value lists and then pass them to evaluate function and then combine them in the evaluate function
I'm looking for an efficient approach. Thanks.