zstd-codec icon indicating copy to clipboard operation
zstd-codec copied to clipboard

TypeError: handle[name] is not a function

Open barrymoore1990 opened this issue 1 year ago • 1 comments

Hi - I'm pretty new to Javascript so apologies if I'm missing something basic

I'm trying to decompress a file & create a new file for the decompressed results. However, I'm getting an error - TypeError: handle[name] is not a function. I've seen another similar issue on here so changed the dataFile line to: const dataFile = streaming.decompress(new Uint8Array(compressed));

Which is producing a console log of Uint8Array(0) []

Thanks for your help in advance

`var fs = require('fs'); const ZstdCodec = require('zstd-codec').ZstdCodec;

ZstdCodec.run(zstd => { // const simple = new zstd.Simple(); const streaming = new zstd.Streaming();

const compressed = "./data/feed_en.json.zst";

const dataFile = streaming.decompress(compressed);

console.log(dataFile);
fs.writeFile('./data/data-file.json', dataFile, err => {
    if (err) {
      console.error(err);
    }
        console.log("Success");
  });

});`

barrymoore1990 avatar Mar 30 '23 07:03 barrymoore1990

You seem to be decompressing a file name rather than it's contents.

riarheos avatar Apr 03 '23 13:04 riarheos

@barrymoore1990 sorry for the too late reply; riarheos 's comment is correct, the file path is not supported.

@riarheos thanks!

yoshihitoh avatar Jul 04 '24 00:07 yoshihitoh