example-d3/webworker.js
/** This axis is inefficient if there are many nodes in the nodeList.
   * But I think it's a pretty useless axis so it's ok. */
This axis is inefficient if there are many nodes in the nodeList.
But I think it's a pretty useless axis so it's ok.
This axis is inefficient if there are many nodes in the nodeList . But I think it ' s a pretty useless axis so it ' s ok .
function followingHelper(nodeList  , nodeTypeNum, nodeName, shouldLowerCase) {
    var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase);
    var nodeMultiSet = new NodeMultiSet(false);
    var cursor = nodeList[0];
    var unorderedFollowingStarts = [];
    for (var i = 0; i < nodeList.length; i++) {
      var node = nodeList[i];
      var start = followingNonDescendantNode(node);
      if (start)
        unorderedFollowingStarts.push(start);
    }
    if (0 === unorderedFollowingStarts.length)
      return {nodes:[]};
    var pos = [], nextPos = [];
    var started = 0;
    while (cursor = followingNode(cursor)) {
      for (var i = unorderedFollowingStarts.length - 1; i >= 0; i--){
        if (cursor === unorderedFollowingStarts[i]) {
          nodeMultiSet.pushSeries();
          unorderedFollowingStarts.splice(i,i+1);
          started++;
        }
      }
      if (started && matcher.matches(cursor)) {
        nodeMultiSet.addNode(cursor);
      }
    }
    console.assert(0 === unorderedFollowingStarts.length);
    for (var i = 0; i < started; i++)
      nodeMultiSet.popSeries();
    return nodeMultiSet.finalize();
  }
function followingHelper ( nodeList , nodeTypeNum , nodeName , shouldLowerCase ) { var matcher = new NodeMatcher ( nodeTypeNum , nodeName , shouldLowerCase ) ; var nodeMultiSet = new NodeMultiSet ( false ) ; var cursor = nodeList [ 0 ] ; var unorderedFollowingStarts = [ ] ; for ( var i = 0 ; i < nodeList . length ; i ++ ) { var node = nodeList [ i ] ; var start = followingNonDescendantNode ( node ) ; if ( start ) unorderedFollowingStarts . push ( start ) ; } if ( 0 === unorderedFollowingStarts . length ) return { nodes : [ ] } ; var pos = [ ] , nextPos = [ ] ; var started = 0 ; while ( cursor = followingNode ( cursor ) ) { for ( var i = unorderedFollowingStarts . length - 1 ; i >= 0 ; i -- ) { if ( cursor === unorderedFollowingStarts [ i ] ) { nodeMultiSet . pushSeries ( ) ; unorderedFollowingStarts . splice ( i , i + 1 ) ; started ++ ; } } if ( started && matcher . matches ( cursor ) ) { nodeMultiSet . addNode ( cursor ) ; } } console . assert ( 0 === unorderedFollowingStarts . length ) ; for ( var i = 0 ; i < started ; i ++ ) nodeMultiSet . popSeries ( ) ; return nodeMultiSet . finalize ( ) ; }
This axis is inefficient if there are many nodes in the nodeList.
This axis is inefficient if there are many nodes in the nodeList .
/*destructive!*/