Skip to content

Instantly share code, notes, and snippets.

@jakl
Created April 24, 2013 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakl/5449459 to your computer and use it in GitHub Desktop.
Save jakl/5449459 to your computer and use it in GitHub Desktop.
Trying to use https://github.com/chrisdickinson/inflate in the browser. Be really awesome if this worked and was faster than https://github.com/imaya/zlib.js
window.Buffer = require('buffer');
var inflate = require('inflate');
var binary_xhr = require('binary-xhr');
var Stream = require('stream').Stream;
var util = require('util');
function FakeStream(){
this.readable = true;
};
util.inherits(FakeStream, Stream)
fakeStream = new FakeStream();
binary_xhr('crime.csv.gz', function(e, data){
var array = new Buffer(new Uint8Array(data));
console.log(array);
fakeStream.pipe(inflate()).on('data', function(chunk){
console.log(chunk);
});
fakeStream.emit('data', array);
fakeStream.emit('end');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment