How To A Use Client Js Code In Nodejs
I've written a js lib for my client to send commands directly to a rmi'ish server. It works nice but now I have to write a bit of server code to connect to the same server. That's
Solution 1:
The simplest way to build a module which is usable as e.g. a node.js module and in the browser is this:
var Foo = function() {
};
Foo.prototype.bar = function() {
};
if(typeof exports !== 'undefined') {
// Node.js or similar
exports.Foo = Foo;
} else {
// Browser -- this is window
this.Foo = Foo;
}
Post a Comment for "How To A Use Client Js Code In Nodejs"