Permalink
Browse files

[fix] extend the thintalk function with core abstraction

  • Loading branch information...
1 parent 80f4ff0 commit 91747b3ef4e7a37b5e7f6826837d41193ed66a91 @AndreasMadsen committed Mar 1, 2012
Showing with 15 additions and 9 deletions.
  1. +15 −9 lib/module.js
View
@@ -11,33 +11,39 @@
(function () {
"use strict";
-
+
// get the core
var core = require('./core/core.js');
-
+
+ function mergeObject(from, to) {
+ for (var name in from) {
+ to[name] = from[name];
+ }
+ }
+
module.exports = function (arg) {
var object;
-
+
if (typeof arg === 'object' && arg !== null) {
object = new core.Listener(arguments);
} else {
- object = new core.Requester(arguments);
+ object = new core.Requester(arguments);
}
-
+
return object;
};
// export core so et it can be easy used in layers
- module.exports.core = core;
-
+ mergeObject(core, module.exports);
+
// export a setLayer method
function setLayer(layerName, object) {
core.layers[layerName] = object;
}
module.exports.setLayer = setLayer;
-
+
// predefine TCP and IPC layers
setLayer('TCP', require('./layers/TCP.js'));
setLayer('IPC', require('./layers/IPC.js'));
-
+
})();

0 comments on commit 91747b3

Please sign in to comment.