documentation/api/weaver.js-1.0.0-pre/weaver.js
function( fn ){
      var self = this;
      var _p = self._private;
      var subsize = self.spreadSize(); // number of pass eles to handle in each thread
      var pass = _p.pass.shift().concat([]); // keep a copy
      var runPs = [];

      for( var i = 0; i < this.length; i++ ){
        var thread = this[i];
        var slice = pass.splice( 0, subsize );

        var runP = thread.pass( slice ).run( fn );

        runPs.push( runP );

        var doneEarly = pass.length === 0;
        if( doneEarly ){ break; }
      }

      return $$.Promise.all( runPs ).then(function( thens ){
        var postpass = new Array();
        var p = 0;

        // fill postpass with the total result joined from all threads
        for( var i = 0; i < thens.length; i++ ){
          var then = thens[i]; // array result from thread i

          for( var j = 0; j < then.length; j++ ){
            var t = then[j]; // array element

            postpass[ p++ ] = t;
          }
        }

        return postpass;
      });
    }
function( fn ){
      var self = this;
      var _p = self._private;
      var subsize = self.spreadSize(); // number of pass eles to handle in each thread
      var pass = _p.pass.shift().concat([]); // keep a copy
      var runPs = [];

      for( var i = 0; i < this.length; i++ ){
        var thread = this[i];
        var slice = pass.splice( 0, subsize );

        var runP = thread.pass( slice ).run( fn );

        runPs.push( runP );

        var doneEarly = pass.length === 0;
        if( doneEarly ){ break; }
      }

      return $$.Promise.all( runPs ).then(function( thens ){
        var postpass = new Array();
        var p = 0;

        // fill postpass with the total result joined from all threads
        for( var i = 0; i < thens.length; i++ ){
          var then = thens[i]; // array result from thread i

          for( var j = 0; j < then.length; j++ ){
            var t = then[j]; // array element

            postpass[ p++ ] = t;
          }
        }

        return postpass;
      });
    }
function ( fn ) { var self = this ; var _p = self . _private ; var subsize = self . spreadSize ( ) ; // number of pass eles to handle in each thread var pass = _p . pass . shift ( ) . concat ( [ ] ) ; // keep a copy var runPs = [ ] ; for ( var i = 0 ; i < this . length ; i ++ ) { var thread = this [ i ] ; var slice = pass . splice ( 0 , subsize ) ; var runP = thread . pass ( slice ) . run ( fn ) ; runPs . push ( runP ) ; var doneEarly = pass . length === 0 ; if ( doneEarly ) { break ; } } return $$ . Promise . all ( runPs ) . then ( function ( thens ) { var postpass = new Array ( ) ; var p = 0 ; // fill postpass with the total result joined from all threads for ( var i = 0 ; i < thens . length ; i ++ ) { var then = thens [ i ] ; // array result from thread i for ( var j = 0 ; j < then . length ; j ++ ) { var t = then [ j ] ; // array element postpass [ p ++ ] = t ; } } return postpass ; } ) ; }
split the data into slices to spread the data equally among threads
split the data into slices to spread the data equally among threads