Skip to content

#272 Added utils classes for JavasScript export function.

  • Added xxxUtils.js, a (direct as possible) translation of utils classes taken from the Java export function.
  • Utils functions can be called via JS console, the next commit adds UI and tests.

Discussion, see: riklubking/escet#27

Addresses #272 (closed)

Fixed after feedback at riklubking/escet#27 (comment 1221642):

  • Removed trailing whitespaces.
  • Introduced MIN_INT / MAX_INT instead of Number.MIN_SAFE_INTEGER / Number.MAX_SAFE_INTEGER, equal to Java Integer min/max.
  • Improved custom exception.
  • Added backticks in the place of all {@code} tags in JSDocs.
  • Fixed capitals: javascript -> JavaScript / javaScript -> JavaScript, number -> Number.
  • Added space for for(), changed ++i to i++.
  • div() returns integers only (truncated result).
  • escape() replaces all instances, not just first instance.
  • Removed makeList() and intToReal() (not required for JavaScript).
  • mod() don't return -0.0 (change to 0.0, same as exp() and others).
  • Refactored project() functions, renamed to projectList and projectString. Fixed projectList().
  • strToInt/strToReal: Remove exception (wasn't thrown), add if check for bounds/NaN instead.
  • Added TODO's with essential info.
  • TODO 1: fmt() function supports only %d and %s at the moment, which is all that's used so far. Will need to extend as more options become required.

  • TODO 2: realToStr() will need to implement some formatting code. This may become a bit messy, perhaps there is some standard function/way to do this, will discuss and do in a separate commit.

Edited by Dennis Hendriks

Merge request reports