No announcement yet.

Undescore.js library

  • Filter
  • Time
  • Show
Clear All
new posts

  • Undescore.js library

    I was reading about some javascript libraries and found underscore and thought it looks like it might be useful and I wanted to experiment with loading a "real" external javascript library - just to see what happens.

    I only tested a couple of methods and ran int to a problem.

    in a transformer step i have

    loggingPrefix = channelName + ':UnderscoreTests:_.isNaN:' + '34.4:[' + _.isNaN(34.4) + ']'); + ' (space):[' + _.isNaN(' ') + ']'); + 'false:[' + _.isNaN(false) + ']'); + 'true:[' + _.isNaN(true) + ']'); + 'undefined:[' + _.isNaN(undefinedVar) + ']');
    They work till the undefined check, which causes an exception:

    ReferenceError: "undefinedVar" is not defined.

    Which Is what I expected the _.isNaN(undefinedVar) to trap and return true.

    I'm not sure why, but I expect it will be something to do with version of javascript (ECMA is suppose to be correct) in mirth?

    Anyone tell me why its happening, I don't want to adopt a library - even if its hailed as a great one if it is unpredictable in mirth. most of what it does as also available in apache commons java libraries, which i have used myself (as wel as mirth using them) with no problems at all.

    Its not desperate, I am just experimenting with Mirth features I have not pushed (i.e loading a larger code template, than I have typically created myself) to date.

    As always, thanks in advance for input

  • #2
    I found this, this morning, that simply suggests that the underscore.js library has made a bad choice of words for the _.isDefined method in that its not to be able to compare typeof == 'undefined' at all but more like uninitialised!!

    I hadn't bothered to read the library code to see. I figured such a revered library would be all straight up!!

    Still it does seem to have a ton of native javascript methods that look useful.



    • #3
      How to?

      I was wondering how did you import JS libraries in Mirth?
      It sounds pretty good and it would compensate lack of ES6 features.
      Than you!