Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The module
- function MyModule(config) {
- // do some connection stuff here
- connected = true
- }
- MyModule.prototype.sendCommand = function() {
- if(connected) {
- // do command
- } else {
- // output an error
- }
- }
- module.exports = MyModule;
- // The script interacting with the module
- var MyModule = require('./MyModule');
- var config = { // config stuff };
- var mod = new MyModule(config);
- var mod.sendCommand;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement