-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Labels
Description
Not sure if v8 staging features are covered, but when using deno run --v8-flags=--js-base-64
or node --js-base-64
or chrome://flags/#enable-javascript-harmony
, the following code gives wrong output:
// foo.ts, run with:
// deno run --v8-flags=--js-base-64 foo.ts
import 'https://deno.land/x/corejs@v3.43.0/index.js'
console.log(new Uint8Array(8).fill(255).toHex()) // gives VfVfVfVfVfVfVfVf
Solution can be adding a check similar to:
var INCORRECT_BEHAVIOR_OR_DOESNT_EXISTS = !Uint8Array || !Uint8Array.prototype.setFromBase64 || !(function () { | |
var target = new Uint8Array([255, 255, 255, 255, 255]); | |
try { | |
target.setFromBase64('MjYyZg==='); | |
} catch (error) { | |
return target[0] === 50 && target[1] === 54 && target[2] === 50 && target[3] === 255 && target[4] === 255; | |
} | |
})(); |