nl_tokens: inflate / deflate core functions
pl_tokens: function launchWorkerProcess ( worker , initialMessage , reader , writer , offset , size , onprogress , onend , onreaderror , onwriteerror ) { var chunkIndex = 0 , index , outputSize , sn = initialMessage . sn , crc ; function onflush ( ) { worker . removeEventListener ( 'message' , onmessage , false ) ; onend ( outputSize , crc ) ; } function onmessage ( event ) { var message = event . data , data = message . data , err = message . error ; if ( err ) { err . toString = function ( ) { return 'Error: ' + this . message ; } ; onreaderror ( err ) ; return ; } if ( message . sn !== sn ) return ; if ( typeof message . codecTime === 'number' ) worker . codecTime += message . codecTime ; // should be before onflush() if ( typeof message . crcTime === 'number' ) worker . crcTime += message . crcTime ; switch ( message . type ) { case 'append' : if ( data ) { outputSize += data . length ; writer . writeUint8Array ( data , function ( ) { step ( ) ; } , onwriteerror ) ; } else step ( ) ; break ; case 'flush' : crc = message . crc ; if ( data ) { outputSize += data . length ; writer . writeUint8Array ( data , function ( ) { onflush ( ) ; } , onwriteerror ) ; } else onflush ( ) ; break ; case 'progress' : if ( onprogress ) onprogress ( index + message . loaded , size ) ; break ; case 'importScripts' : //no need to handle here case 'newTask' : case 'echo' : break ; default : console . warn ( 'zip.js:launchWorkerProcess: unknown message: ' , message ) ; } } function step ( ) { index = chunkIndex * CHUNK_SIZE ; // use `<=` instead of `<`, because `size` may be 0. if ( index <= size ) { reader . readUint8Array ( offset + <mask> , Math . min ( CHUNK_SIZE , size - index ) , function ( array ) { if ( onprogress ) onprogress ( index , size ) ; var msg = index === 0 ? initialMessage : { sn : sn } ; msg . type = 'append' ; msg . data = array ; // posting a message with transferables will fail on IE10 try { worker . postMessage ( msg , [ array . buffer ] ) ; } catch ( ex ) { worker . postMessage ( msg ) ; // retry without transferables } chunkIndex ++ ; } , onreaderror ) ; } else { worker . postMessage ( { sn : sn , type : 'flush' } ) ; } } outputSize = 0 ; worker . addEventListener ( 'message' , onmessage , false ) ; step ( ) ; }