src/parseDom.js
function convertToNode (element) {
  switch (element.type) {
    case 'tag':
      return ['a', 'p', 'strong', 'em', 'b', 'em'].indexOf(element.name) !== -1
           ? {
             name: element.name,
             attrs: filterAttributes(element.name, element.attribs),
             children: element
               .children
               .map(child => convertToNode(child))
               .filter(child => child !== null)
           }
           : null

    case 'text':
      return element.data

    default:
      return '---'
  }
}
function convertToNode (element) {
  switch (element.type) {
    case 'tag':
      return ['a', 'p', 'strong', 'em', 'b', 'em'].indexOf(element.name) !== -1
           ? {
             name: element.name,
             attrs: filterAttributes(element.name, element.attribs),
             children: element
               .children
               .map(child => convertToNode(child))
               .filter(child => child !== null)
           }
           : null

    case 'text':
      return element.data

    default:
      return '---'
  }
}
function convertToNode ( element ) { switch ( element . type ) { case 'tag' : return [ 'a' , 'p' , 'strong' , 'em' , 'b' , 'em' ] . indexOf ( element . name ) !== - 1 ? { name : element . name , attrs : filterAttributes ( element . name , element . attribs ) , children : element . children . map ( child => convertToNode ( child ) ) . filter ( child => child !== null ) } : null case 'text' : return element . data default : return '---' } }
private convert a cheerio element into a JS object representing a node
private convert a cheerio element into a JS object representing a node