buffer icon indicating copy to clipboard operation
buffer copied to clipboard

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

Open 307914070 opened this issue 4 years ago • 6 comments
trafficstars

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)) })

307914070 avatar May 08 '21 08:05 307914070

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

vweevers avatar May 08 '21 08:05 vweevers

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.

swansontec avatar Jul 23 '21 20:07 swansontec

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

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

AlexJeffcott avatar Aug 03 '21 10:08 AlexJeffcott

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

  • latest v6 (not IE 11 compatible) = 920k
  • latest v5 (IE 11 compatible) = 10,2M

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.

fmagaldea avatar Aug 04 '21 17:08 fmagaldea

@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.

Uzlopak avatar Jan 26 '22 02:01 Uzlopak

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

xujintai123 avatar Apr 12 '23 09:04 xujintai123