How to monkeypatch Typed Arrays into ECMAScript 3 JavaScript, specifically Uint8Array? (IDE necessity in Adobe ESTK)

122 views Asked by At

I'm working on an Adobe ExtendScript (.jsx), which is basically a subset of the older ECMAScript 3 JavaScript standard.

In order to use open source developed code, written in JS ECMAScript 5+, I need to implement Typed Arrays, (through Monkeypatching or other technique), in order to differentiate Uint8Array from "regular" Arrays.

1

There are 1 answers

2
AudioBubble On

You can try this polyfill with ExtendScript. It does not work right out of the box though:

  • You need to search and replace the variable final as ExtendScript thinks it's a reserved keyword. Just prepend with underscore (ie. _final).
  • self given as argument to the patch must be replaced with this

I have done very limited test with this polyfill in ExtendScript but seem to work fairly fine for simpler things, even with the reduced performance you would otherwise would have.

It will return true for array instanceof Uint8Array (assuming of course array was declared as one).