"use strict";

var
    pako = require('pako');

module.exports = function flateDecode(buffer) {
    return String.fromCharCode.apply(null, pako.inflate(toArrayBuffer(buffer)));
};

// http://stackoverflow.com/a/12101012/778272
function toArrayBuffer(buffer) {
    var ab = new ArrayBuffer(buffer.length);
    var view = new Uint8Array(ab);
    for (var i = 0; i < buffer.length; ++i) {
        view[i] = buffer[i];
    }
    return ab;
}

"use strict";

var
    pako = require('pako');

module.exports = function flateDecode(buffer) {
    return pako.inflate(buffer, {to:'string'});
};

Fix truncated result from pako
Fix truncated result from pako

I still don't know how to correctly call pako. Looks like it was truncating to 16k only if I passed a Uint8Array. Now I'm passing a Buffer and it works, although the docs don't tell anything about Buffers being passed as input.
