function nodeStream()

in src/helper/merge-html-plugin.ts [46:71]


  function nodeStream (node: Node): Event[] {
    const result: Event[] = [];
    (function _nodeStream (node, offset) {
      for (let child = node.firstChild; child != null; child = child.nextSibling) {
        if (child.nodeType === 3) {
          offset += child.nodeValue?.length ?? 0;
        } else if (child.nodeType === 1) {
          result.push({
            event: 'start',
            offset,
            node: child
          });
          offset = _nodeStream(child, offset);
          if (tag(child).match(/br|hr|img|input/) == null) {
            result.push({
              event: 'stop',
              offset,
              node: child
            });
          }
        }
      }
      return offset;
    })(node, 0);
    return result;
  }