inexorabletash/polyfill

Using typedarray.js standalone.

Closed this issue · 5 comments

Hi, I'm trying to polyfill typed arrays. My code works when polyfill.js is included but it doesn't work if only typedarray.js is included.

How may I get typedarray.js to run standalone?

Thanks!

typedarray.js requires at least es5 support, so you also need at least a subset of es5.js

(which is odd since typedarray.js itself polyfills Object.defineProperty. But the tests pull in es5.js so apparently I introduced a dependency at some point)

Hm, I tried including es5.js before typedarray.js but same issue (TypedArray.from doesn't exist).

Do these need to be bundled together in some particular way?

Thanks!

What browser/version are you trying? Can you provide a code snippet?

In IE8 it works as expected pulling in just es5.js:

Uint8Array.from([1,2,3]).get(1); // 2

(Note the non-standard get() since IE8 doesn't support arbitrary getters/setters)

That's odd. I'm testing in IE 11.0.9600. I added es5.js and removed typedarray.js to see if Uint8Array.from() works and it doesn't. I'm not sure what would explain the inconsistent behavior.

Fortunately I do have it working with polyfill.js which is only ~156 KBs larger than es5.js and typedarray.js combined, so I think that will work well enough!

Thanks for your help!

Ooops, when I wrote "pulling in just es5.js" I meant in addition to typedarray.js.