UNPKG

581 BJavaScriptView Raw
1var util = require('util');
2var net = require('net');
3var repl = require('repl');
4
5var replI = module.exports = function (config) {
6 this.config = util.extend(
7 Object.create(replI.defaultConfig),
8 config || {}
9 );
10 this.listen();
11};
12
13replI.defaultConfig = {
14 host: 'localhost',
15 port: 5001,
16 message: 'dataflo.ws$ '
17};
18
19replI.prototype.listen = function () {
20 var config = this.config;
21
22 console.log('REPL server running on %s:%s', config.host, config.port);
23
24 net.createServer(function (socket) {
25 repl.start(config.message, socket);
26 }).listen(config.port, config.host);
27};