Created
February 22, 2012 13:52
-
-
Save janjongboom/1885247 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function MyObject () { | |
// do stuff | |
} | |
// now to export this as a nodejs module do | |
module.exports = MyObject; | |
// ===== | |
// in another file (in the same folder) you can now do | |
var MyObject = require("./MyObject"); | |
// use it just like before | |
var obj = new MyObject(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Summary, here's the changes I needed to make:
var FreshBooks_Element = require('./Element');
After the declaration of the function constructor in TimeEntry.js:
function FreshBooks_TimeEntry()
{
this.elementName = "time_entry";
...
}
Added, per http://nodejs.org/api/modules.html#module.exports and http://stackoverflow.com/questions/8296379/create-a-class-in-nodejs:
module.exports = FreshBooks_TimeEntry;
After the declaration of the function constructor in Element.js:
function FreshBooks_Element()
{
...
}
Added:
module.exports = FreshBooks_Element;