1
for (var items in _selectedContexts) {
  var downloadModel = __parsed[__parsed[items].toString().split("/")[1]][__parsed[items].toString().split("/")[2]];
  var length = downloadModel["Value"].length;
  var base64 = downloadModel["Value"];
  var bytes =  new Uint8Array(length);
  while (length--) {
    bytes[length] = base64.charCodeAt(length);
  }
  MessageToast.show(bytes.length);
}

How can I initialize a Uint8Array in UI5? I always get "Uint8Array is not defined" in SAP Web IDE as an error message. Do I need to import any special libraries? I'm also using the latest SAPUI5 version and Chrome for testing so it shouldn't be a problem I guess?

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
L. Busekrus
  • 412
  • 1
  • 4
  • 11
  • Where (in which environment) will the script be executed that you are editing in web ide? What build tool chain is there? – Bergi Jun 19 '20 at 19:05
  • Hi thanks for trying to figure it out for me. It's designed to be Fiori app therefore it will be launched over the Fiori launchpad. I hope this is the information you where looking for. – L. Busekrus Jun 19 '20 at 19:16
  • I don't know Web IDE and couldn't find anything on the web about it. The error message sounds very much like a linter or typechecker warning, and there should be a configuration file for this somewhere that would let you choose ES6 as the language. – Bergi Jun 19 '20 at 19:37

1 Answers1

3

Yes, you can ignore the message as long as your target browser supports the object. Uint8Array was added to a somewhat newer JS specification (ECMAScript 2015 aka. ES6). In order to make SAP Web IDE understand and parse ES6, add es6 to the ESLint environment settings:

  1. Go to Project settings > Code Checking > JavaScript
  2. Expand the Validator Configuration panel
  3. Add "es6": true to the env object:
    "env": {
      "es6": true,
      "...": "..."
    }
    
    This will edit the internal .eslintrc file accordingly.
  4. Save the settings.
Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170