Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function lz77_decompress(input, dictlen){
- let output="", drl=0, dl=dictlen;
- for(let i=0; i<input.length; i++){
- if( input[i].length==0 ){
- output+=input[i].char;
- }else{
- let j=drl-dl+input[i].index, k=j;
- let l2=input[i].length+input[i].index-Math.max(0, dl-drl),
- len=drl-dl+Math.min(dl, l2);
- while( j<len ){
- output+=output[j];
- j++;
- }
- while( j<l2 ){
- output+=output[k];
- k++;
- j++;
- }
- output+=input[i].char;
- }
- drl+=input[i].length+1;
- }
- return output;
- }
Advertisement
Add Comment
Please, Sign In to add comment