Created
March 5, 2018 18:43
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ = require "jquery" | |
pako = require('pako') | |
bz2 = require('unbzip2-stream') | |
BrowserStdout = require('browser-stdout') | |
decoder = new TextDecoder("utf-8") | |
stream = new WritableStream | |
start :(controller) -> | |
console.log "start",controller | |
write: (chunk,controller) -> | |
buffer = new ArrayBuffer(2) | |
view = new Uint16Array(buffer) | |
view[0] = chunk | |
decoded = new TextDecoder("utf-8").decode(chunk) | |
result = pako.ungzip(chunk) | |
# decoded = decoder.decode(view, { stream: true }) | |
# console.log '---->',result.result | |
console.log new TextDecoder("utf-8").decode(result) | |
close : (controller) -> | |
console.log "close",controller | |
abort: (reason) -> | |
console.log "abort",reason | |
on: (data)-> | |
console.log data | |
yo = (watch,start,end)-> | |
fetch watch, | |
headers: | |
#"Range": "bytes=#{start}-#{end}" | |
"Accept-Encoding" : "gzip" | |
"Content-Encoding" : "gzip, deflate" | |
# mode : "no-cors", | |
.then (response)-> | |
# response.body | |
# len = response.headers.get('Content-Length') | |
console.dir response | |
console.log await response.text() | |
.then (body)-> | |
# console.log body,"here" | |
# body.pipeTo(stream) | |
.catch (error) -> | |
console.log(error) | |
$(document).ready -> | |
yo "http://localhost:3000/lib/package.json.gz",0,20000 | |
# yo "http://localhost:3000/index.html",0,100000 | |
# yo "http://localhost:3000/lib/enwiki-20170820.xml.bz2",0,100000 | |
# yo "https://dumps.wikimedia.your.org//enwiki/latest/enwiki-latest-abstract.xml-rss.xml" | |
# yo("http://dumps.wikimedia.your.org//enwiki/latest/enwiki-latest-abstract.xml.gz",0,10000) | |
# yo("https://dumps.wikimedia.your.org//enwiki/latest/enwiki-latest-abstract1.xml.gz",0,10000) | |
console.log "hi spencer" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment