src/parseDom.js
function convertToText (object) {
  switch (typeof object) {
    case 'string':
      return object

    case 'object':
      const attrs = toPairs(object.attrs)
        .map(([name, value]) => `${name}="${value}"`)

      const tag = [object.name].concat(attrs)
                               .join(' ')

      const children = object
        .children
        .map(child => convertToText(child))
        .join('')

      return `<${tag}>${children}</${object.name}>`
  }
  return '<' + object.name + '>'
}
function convertToText (object) {
  switch (typeof object) {
    case 'string':
      return object

    case 'object':
      const attrs = toPairs(object.attrs)
        .map(([name, value]) => `${name}="${value}"`)

      const tag = [object.name].concat(attrs)
                               .join(' ')

      const children = object
        .children
        .map(child => convertToText(child))
        .join('')

      return `<${tag}>${children}</${object.name}>`
  }
  return '<' + object.name + '>'
}
function convertToText ( object ) { switch ( typeof object ) { case 'string' : return object case 'object' : const attrs = toPairs ( object . attrs ) . map ( ( [ name , value ] ) => ` ${ name } ${ value } ` ) const tag = [ object . name ] . concat ( attrs ) . join ( ' ' ) const children = object . children . map ( child => convertToText ( child ) ) . join ( '' ) return ` ${ tag } ${ children } ${ object . name } ` } return '<' + object . name + '>' }
private convert a JS object node into a text
private convert a JS object node into a text