Q:

Exporting class type containing multiple values

I wrote some code here that takes data from a .JSON file and turns it into an stringified object.
I need to export the Source and Destination classes here: 
class Source {
    constructor(source_address, source_lat, source_lng, scan_type) {
        this.source_address = source_address;
        this.source_lat = source_lat;
        this.source_lng = source_lng;
    }
};

class Destination {
    constructor(dest_address, dest_lat, dest_lng, scan_type) {
        this.dest_address = dest_address;
        this.dest_lat = dest_lat;
        this.dest_lng = dest_lng;
        this.scan_type = scan_type;
    }
};

that I initialize like so:
//Initialize Source
obj.forEach(block => {
    //initialize Values
    var sourceClass = new Source(block.source_address, block.source_lat, block.source_lng, block.scan_type);
});
...
//Initialize Destination
obj.forEach(block => {
    //initialize Destination
    var destinationClass = new Destination(block.dest_address, block.dest_lat, block.dest_lng, block.scan_type);
});

into a separate JavaScript file.
I've tried using module.export(), and "requiring" my javascript file, but nothing seems to work.
How can I export my Source and Destination class with all it's values to another Javascript file?

A:

In your module:
exports.Source = Source;
exports.Destination = Destination;

Using it:
var mod = require("yourmodule");
var Source = mod.Source;
var Destination = mod.Destination;

If you're using ES2015 (even though ES2015 modules aren't supported by NodeJS yet), you can use destructuring syntax to simplify use a bit:
let { Source, Destination } = require("yourmodule");

(Which looks similar to what import will look when ES2015 modules are supported [but works fundamentally differently].)

