Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gzip and blosc decoders #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

manzt
Copy link

@manzt manzt commented Sep 30, 2020

Not sure if this would be on interest to the project, but I added support for gzip and blosc compression. Also added new fixtures and tests for the supported codecs.

@manzt
Copy link
Author

manzt commented Sep 30, 2020

The codecs can be expensive to load upfront, so an option is to make codecs load dynamically:

let blosc
let pako
const decoders = new Map()
   .set('zlib', async c => {
     if (!pako) pako = require('pako')
     return pako.inflate(c)
   })
   .set('gzip', async c => {
     if (!pako) pako = require('pako')
     return pako.ungzip(c)
   })
   .set('blosc', async c => {
     if (!blosc) {
       const Blosc = require('numcodecs/blosc')
       blosc = new Blosc()
     }
     return blosc.decode(c)
   })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant