nl_tokens: In the event that index chunks aren t available from an external source it winds up saving time to do a fast pass over the data to compute them . This allows us to parse a single contig at a time using jBinary .
pl_tokens: function computeIndexChunks ( buffer ) { var BLOCK_SIZE = 65536 ; var view = new jDataView ( buffer , 0 , buffer . byteLength , true /* little endian */ ) ; var minBlockIndex = Infinity ; var contigStartOffsets = [ ] ; view . getInt32 ( ) ; // magic var n_ref = view . getInt32 ( ) ; for ( var j = 0 ; j < n_ref ; j ++ ) { contigStartOffsets . push ( view . tell ( ) ) ; var n_bin = view . getInt32 ( ) ; for ( var i = 0 ; i < n_bin ; i ++ ) { view . getUint32 ( ) ; // bin ID var n_chunk = view . getInt32 ( ) ; view . skip ( n_chunk * 16 ) ; } var n_intv = view . getInt32 ( ) ; if ( n_intv ) { var offset = VirtualOffset . fromBlob ( <mask> . getBytes ( 8 ) , 0 ) , coffset = offset . coffset + ( offset . uoffset ? BLOCK_SIZE : 0 ) ; minBlockIndex = coffset ? Math . min ( coffset , minBlockIndex ) : BLOCK_SIZE ; view . skip ( ( n_intv - 1 ) * 8 ) ; } } contigStartOffsets . push ( view . tell ( ) ) ; // At this point, `minBlockIndex` should be non-Infinity (see #405 & #406) return { chunks : _ . zip ( _ . initial ( contigStartOffsets ) , _ . rest ( contigStartOffsets ) ) , minBlockIndex } ; }