Skip to content

Latest commit

 

History

History
46 lines (38 loc) · 792 Bytes

README.md

File metadata and controls

46 lines (38 loc) · 792 Bytes

Balls

Collection of helpers to deal with compressed data

Usage

local Zlib = require('balls').Zlib

local file = require('fs').createReadStream(__dirname .. '/test.gz', {
  chunk_size = 1,
})

local gunzip = Zlib.inflator()
gunzip:on('data', function (text)
  print('CHUNK', text)
end)
gunzip:on('end', function ()
  print('GUNZIPPED')
end)
file:pipe(gunzip)

local Zip = require('balls').Zip
local uzip = Zip:new(
    require('fs').createReadStream(__dirname .. '/test.zip'),
    {
      -- TODO: auto guess
      inflateOptions = -15
    }
  )
  -- zip entry parsed
  :on('entry', function (entry)
    p('E', entry.name, entry.comp_size)
  end)
  -- zipball read entirely
  :on('end', function ()
    print('UNZIPPED')
  end)

License

MIT