Can you specify multiple classes in a module? If so, how do you reference them individually after a requires() invocation?
--- modules/animals.js ---
class Animal { } class Dog extends Animal { } class Cat extends Animal { }
exports = Dog, Cat;
var animals = require("animals");
var d = new Dog(); var c = new Cat();
Uncaught ReferenceError: "Dog" is not defined at line 2 col 5 var d=new Dog();
Uncaught ReferenceError: "Cat" is not defined at line 3 col 5 var c=new Cat();
@MarcEvan started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Can you specify multiple classes in a module? If so, how do
you reference them individually after a requires() invocation?
--- modules/animals.js ---
class Animal { }
class Dog extends Animal { }
class Cat extends Animal { }
exports = Dog, Cat;
var animals = require("animals");
var d = new Dog();
var c = new Cat();
Uncaught ReferenceError: "Dog" is not defined
at line 2 col 5
var d=new Dog();
Uncaught ReferenceError: "Cat" is not defined
at line 3 col 5
var c=new Cat();