• Sat 2018.09.08

    I am attempting to test a module function between var exports={}; statements.

    http://www.espruino.com/Writing+Modules


    function testLED(pin) {
      this.p = pin[0];
    };
    
    exports = testLED;
    
    
    testLED.prototype.testUR = function() {
      var nInt = 42;
        console.log( "inside testUR() " + nInt );
    };
    
    exports.create = function() {
      return new testLED([A5]);
    };
    



    The IDE shows correct syntax check in right-hand editor pane.

    On immediate send to device, Uncaught ReferenceError: "testUR" is not defined
    despite the fact I just created the function definition. Observing the 'this' contents confirms this


    1v99 (c) 2018 G.Williams
    >Uncaught ReferenceError: "testUR" is not defined
     at line 1 col 11
    exports = testUR;
              ^
    =undefined
    >this
    ={
      "E": function () { [native code] },
      "exports": {  },
      "testLED": function (pin) { ... },
      "ReferenceError": function () { [native code] },
    

    Ideas anyone?

About

Avatar for Robin @Robin started