thejoshwolfe / yazl

yet another zip library for node
MIT License
341 stars 45 forks source link

2.5.0 TypeError: this is not a typed array #47

Closed chadn closed 5 years ago

chadn commented 6 years ago

We use gulp-zip which uses yazl and a few days ago our build broke because of changes in 2.5.0 Here's the error

node_modules/gulp-zip/node_modules/yazl/index.js:111
var eocdrSignatureBuffer = Buffer.from([0x50, 0x4b, 0x05, 0x06]);
                                  ^
TypeError: this is not a typed array.
  at Function.from (na  at Object.<anonymous> (node_modules/gulp-zip/node_modules/yazl/index.js:111:35)

I forked gulp-zip and hardcoded yazl to use version 2.4.3 till this is fixed. Hopefully will be fixed soon.

deepakpadukone20 commented 6 years ago

for node < v4 we need to have something like below instead of directly using Buffer.from

function bufferFrom(content) {
  try {
    return Buffer.from(content);
  } catch(e) {
    if (Object.prototype.toString.call(content) !== '[object String]') {
      throw new TypeError("separator must be a string");
    }
    return new Buffer(content);
  }
}
Kanwar007-zz commented 5 years ago

I am also getting this error. Could you please tell me when we get the resolve version.

thejoshwolfe commented 5 years ago

Thanks for the reports! Will definitely fix this issue. (Thanks @deepakpadukone20 for #48 ) This is a holiday week in the US, so I might not have time to do this right away.

chetankh23 commented 5 years ago

When can we expect the fix for this to be released ?

thejoshwolfe commented 5 years ago

I've just gotten travis set up to test yazl against old versions of node. I should be able to fix this tonight.

thejoshwolfe commented 5 years ago

yazl version 2.5.1 is now published. This should resolve all the compatibility issues.

Thank you all for your patience!