Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[fix] Changed require('sys') to require('util') for compatibility wit…

…h node v0.8
  • Loading branch information...
commit 743bf82fce55061dfe8c954638f2c860542fcce6 1 parent c3e5853
@blakmatrix blakmatrix authored
View
6 example/example.js
@@ -1,4 +1,4 @@
-var sys = require('sys');
+var util = require('util');
var Worker = require('../lib/worker').Worker;
@@ -9,10 +9,10 @@ worker.postMessage({
});
worker.onmessage = function (msg) {
- sys.puts(msg.hello);
+ util.puts(msg.hello);
};
worker.addListener('message', function (msg) {
- sys.puts(msg.hello);
+ util.puts(msg.hello);
worker.terminate();
});
View
8 lib/tcpworker.js
@@ -1,12 +1,12 @@
var tcp = require("net");
-var sys = require("sys");
+var util = require('util');
var worker = require("./worker");
var MESSAGE_SPLITTER = "\r\n";
var HANDSHAKE = "HANDSHAKE";
function debug(msg) {
- //sys.error("Workerdebug "+process.pid+" - "+msg)
+ //util.error("Workerdebug "+process.pid+" - "+msg)
}
var WorkerServer = {};
@@ -51,7 +51,7 @@ exports.startWorker = function (port, hostname) {
port: port,
hostname: hostname
});
- sys.puts("System up");
+ util.puts("System up");
return w;
}
@@ -72,7 +72,7 @@ function WorkerChild (eventDest, filename, paras) {
this.queue = [];
}
-sys.inherits(WorkerChild, worker._WorkerChild);
+util.inherits(WorkerChild, worker._WorkerChild);
WorkerChild.prototype.connect = function (paras) {
var self = this;
View
8 lib/tcpworkerserver.js
@@ -1,5 +1,5 @@
-var sys = require("sys");
+var util = require('util');
var port = parseInt(process.ARGV[2], 10);
var filename = process.ARGV[3];
@@ -11,11 +11,11 @@ var processes = [];
worker.onmessage = function (filename) {
port = port + 1;
var curPort = port;
- sys.error("Starting child "+curPort);
+ util.error("Starting child "+curPort);
var child = process.createChildProcess("node", [filename, curPort]);
child.addListener("error", function (data) {
- sys.error(data);
+ util.error(data);
});
var init = false;
@@ -24,7 +24,7 @@ worker.onmessage = function (filename) {
init = true;
worker.postMessage(curPort);
}
- sys.puts(data);
+ util.puts(data);
});
child.addListener("exit", function (data) {
View
12 lib/worker.js
@@ -1,6 +1,6 @@
// An implementation of the web worker API for node.js
-var sys = require('sys');
+var util = require('util');
var child_process = require('child_process');
var constants = require('./constants');
@@ -15,7 +15,7 @@ var DEBUG = constants.DEBUG;
function debug(msg) {
if (DEBUG) {
- sys.error("debug "+process.pid+" - "+msg)
+ util.error("debug "+process.pid+" - "+msg)
}
}
@@ -53,7 +53,7 @@ var Worker = function (filename, impl, options) {
this.workerIndex = workerIndex++;
};
-sys.inherits(Worker, process.EventEmitter);
+util.inherits(Worker, process.EventEmitter);
Worker.prototype.postMessage = function (payload) {
var message = JSON.stringify(payload);
this.impl.postMessage(message);
@@ -230,7 +230,7 @@ WorkerChild.prototype = {
var workerProcess;
var i = 0;
function WorkerProcess(eventDest) {
- sys.print(HANDSHAKE+MESSAGE_SPLITTER);
+ util.print(HANDSHAKE+MESSAGE_SPLITTER);
var self = this;
this.eventDest = eventDest;
var stdin = process.openStdin();
@@ -244,7 +244,7 @@ function WorkerProcess(eventDest) {
WorkerProcess.prototype = {
postMessage: function (message) {
//debug("Process posting message "+message);
- sys.print(message+MESSAGE_SPLITTER);
+ util.print(message+MESSAGE_SPLITTER);
},
handleData: WorkerChild.prototype.handleData,
@@ -270,7 +270,7 @@ function WorkerNode (impl, options) {
});
})
}
-sys.inherits(WorkerNode, process.EventEmitter);
+util.inherits(WorkerNode, process.EventEmitter);
WorkerNode.prototype.postMessage = function (payload) {
this.impl.postMessage(JSON.stringify(payload));
View
8 test/common.js
@@ -7,16 +7,16 @@ exports.libDir = path.join(exports.testDir, "../../lib");
require.paths.unshift(exports.libDir);
var assert = require('assert');
-var sys = require("sys");
+var util = require('util');
exports.path = path;
var ok = assert.ok;
assert.ok = function (bool, msg) {
if(bool) {
- sys.print("OK ")
+ util.print("OK ")
} else {
- sys.print("NOT OK ")
+ util.print("NOT OK ")
}
- sys.puts(msg);
+ util.puts(msg);
}
View
2  test/fixtures/worker.js
@@ -6,7 +6,7 @@ exports.libDir = path.join(exports.testDir, "../../lib");
require.paths.unshift(exports.libDir);
-var sys = require("sys");
+var util = require('util');
var worker = require("worker").worker;
worker.onmessage = function (msg) {
Please sign in to comment.
Something went wrong with that request. Please try again.