調用 ...
function fold(node){ var map = new Map(); map.set(node.tagName,1); [].reduce.call(node.children,(acc,child)=>{ deal(acc,fold(child)); return acc },map) return map } function deal(srcMap,tarMap){ tarMap.forEach((value,tagName)=>{ var newV = value + ~~srcMap.get(tagName); srcMap.set(tagName,newV); }) }
調用