feross / buffer

The buffer module from node.js, for the browser.
Other
1.79k stars 230 forks source link

the code 2 ** 8 not work in IE 11. #294

Open 307914070 opened 3 years ago

307914070 commented 3 years ago

in the pulgins "buffer", The code below is not work in IE 11.

Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) { offset = offset >>> 0 validateNumber(offset, 'offset') const first = this[offset] const last = this[offset + 7] if (first === undefined || last === undefined) { boundsError(offset, this.length - 8) }

const lo = first + this[++offset] * 2 8 + this[++offset] * 2 * 16 + this[++offset] 2 24

const hi = this[++offset] + this[++offset] * 2 8 + this[++offset] * 2 * 16 + last 2 24

return BigInt(lo) + (BigInt(hi) << BigInt(32)) })

vweevers commented 3 years ago

That's expected because buffer@6 dropped support of IE11: https://github.com/feross/buffer/commit/840160f352ff0d8e88d4ac308a1640fd278f50fc

swansontec commented 3 years ago

This issue also affects certain older Android 6 devices, like the Oukitel K6000. The exponentiation operator was introduced in ES2016, which makes it newer than things like the import keyword or arrow functions. However, it's not just the exponentiation operator - buffer also includes default parameters to functions and other ES6 syntax.

We are going to work around this issue on our end by running buffer through Babel during our build step, but it would be preferable to to skip this.

AlexJeffcott commented 3 years ago

That's expected because buffer@6 dropped support of IE11: 840160f

should the readme mention this as it currently says 'all browsers'?

fmagaldea commented 3 years ago

As of 4th of August 2021, after 8 months of release of the v6, weekly downloads stats has spoken:

You can check any other npm package, no one - that has such a success like this one - has so slow migration in such a long time.

I think it's clear that community chose version compatible with IE 11 (and old mobile devices). It would be nice to take these feedback in account, but I also understand you don't force anybody to upgrade - luckily. Of course we can use some tricks while building, but in my case I prefer to not complexify and maintain extra build steps.

Uzlopak commented 2 years ago

@feross

With PR #308 the doublestar is avoided by preferring precalculated values. So atleast the IE11 fraction should have not the issue by having a totally breaking buffer implementation.

xujintai123 commented 1 year ago

if use v6 in IE 11, use babel to extra transpile