Comparing version 2.0.0 to 2.0.1
@@ -17,2 +17,8 @@ | ||
/** | ||
* Expose zmq version. | ||
*/ | ||
exports.version = zmq.zmqVersion(); | ||
/** | ||
* Map of socket types. | ||
@@ -75,3 +81,3 @@ */ | ||
ctx = new zmq.Context(io_threads); | ||
process.on('exit', function() { | ||
process.on('exit', function(){ | ||
// ctx.close(); | ||
@@ -96,2 +102,3 @@ ctx = null; | ||
this._outgoing = []; | ||
this._shouldFlush = true; | ||
this._watcher = new IOWatcher; | ||
@@ -185,5 +192,5 @@ this._watcher.callback = this._flush.bind(this); | ||
this._zmq.bindSync(addr); | ||
} catch (e) { | ||
} catch (err) { | ||
this._watcher.start(); | ||
throw e; | ||
throw err; | ||
} | ||
@@ -236,3 +243,3 @@ this._watcher.start(); | ||
* | ||
* @param {String|Buffer} msg | ||
* @param {String|Buffer|Array} msg | ||
* @param {Number} flags | ||
@@ -244,10 +251,14 @@ * @return {Socket} for chaining | ||
Socket.prototype.send = function(msg, flags) { | ||
// allow strings etc | ||
if (!Buffer.isBuffer(msg)) { | ||
msg = new Buffer(String(msg), 'utf8'); | ||
if (Array.isArray(msg)) { | ||
for (var i = 0, len = msg.length; i < len; i++) { | ||
this.send(msg[i], i < len - 1 | ||
? zmq.ZMQ_SNDMORE | ||
: flags); | ||
} | ||
} else { | ||
if (!Buffer.isBuffer(msg)) msg = new Buffer(String(msg), 'utf8'); | ||
this._outgoing.push([msg, flags || 0]); | ||
if (!(flags & zmq.ZMQ_SNDMORE)) this._flush(); | ||
} | ||
this._outgoing.push([msg, flags || 0]); | ||
this._flush(); | ||
return this; | ||
@@ -260,3 +271,5 @@ }; | ||
Socket.prototype._flush = function() { | ||
var args; | ||
var self = this | ||
, flushing = false | ||
, args; | ||
@@ -273,6 +286,3 @@ // Don't allow recursive flush invocation as it can lead to stack | ||
if (!this._outgoing.length) { | ||
flags &= ~zmq.ZMQ_POLLOUT; | ||
} | ||
if (!this._outgoing.length) flags &= ~zmq.ZMQ_POLLOUT; | ||
if (!flags) break; | ||
@@ -287,4 +297,10 @@ | ||
this.emit.apply(this, emitArgs); | ||
if (this._zmq.state != zmq.STATE_READY) { | ||
// Allows flush to complete before handling received messages. | ||
(function(emitArgs) { | ||
process.nextTick(function(){ | ||
self.emit.apply(self, emitArgs); | ||
}) | ||
})(emitArgs); | ||
if (zmq.STATE_READY != this._zmq.state) { | ||
this._flushing = false; | ||
@@ -304,4 +320,4 @@ return; | ||
} | ||
} catch (e) { | ||
this.emit('error', e); | ||
} catch (err) { | ||
this.emit('error', err); | ||
} | ||
@@ -335,4 +351,3 @@ | ||
exports.socket = | ||
exports.createSocket = function(type, options) { | ||
exports.socket = function(type, options) { | ||
var sock = new Socket(type); | ||
@@ -339,0 +354,0 @@ for (var key in options) sock[key] = options[key]; |
{ | ||
"name": "zmq", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Bindings for node.js to zeromq", | ||
@@ -11,6 +11,8 @@ "main": "index", | ||
"devDependencies": { | ||
"should": "0.3.1" | ||
"should": "*" | ||
, "jade": "*" | ||
, "dox": "*" | ||
}, | ||
"engines": { | ||
"node": ">=0.3.0 <0.7.0" | ||
"node": ">=0.3.0 < 0.7.0" | ||
}, | ||
@@ -17,0 +19,0 @@ "contributors": [ |
# node-zeromq | ||
ØMQ bindings for node.js | ||
[ØMQ](http://www.zeromq.org/) bindings for node.js. | ||
@@ -15,3 +15,3 @@ ## Installation | ||
```js | ||
var zmq = require('zeromq') | ||
var zmq = require('zmq') | ||
, sock = zmq.socket('push'); | ||
@@ -32,3 +32,3 @@ | ||
var zmq = require('zeromq') | ||
var zmq = require('zmq') | ||
, sock = zmq.socket('pull'); | ||
@@ -58,1 +58,29 @@ | ||
## Contributors | ||
Authored by Justin Tulloss, maintained by Shripad K and TJ Holowaychuk. To contribute please ensure _all_ tests pass, and do your best to maintain the style used within the rest of the library. | ||
Output of `git summary`: | ||
project: zeromq.node | ||
commits: 260 | ||
files : 38 | ||
authors: | ||
114 Justin Tulloss 43.8% | ||
53 Tj Holowaychuk 20.4% | ||
48 Stéphan Kochen 18.5% | ||
12 jeremybarnes 4.6% | ||
10 TJ Holowaychuk 3.8% | ||
9 mike castleman 3.5% | ||
3 Yaroslav Shirokov 1.2% | ||
2 Corey Jewett 0.8% | ||
2 mgc 0.8% | ||
1 rick 0.4% | ||
1 Matt Crocker 0.4% | ||
1 Joshua Gourneau 0.4% | ||
1 Micheil Smith 0.4% | ||
1 Jeremy Barnes 0.4% | ||
1 nponeccop 0.4% | ||
1 Paul Bergeron 0.4% | ||
@@ -5,2 +5,6 @@ | ||
// version | ||
zmq.version.should.match(/^\d+\.\d+\.\d+$/); | ||
// socket types | ||
@@ -36,2 +40,2 @@ | ||
zmq.createSocket.should.be.a('function'); | ||
zmq.socket.should.be.a('function'); |
@@ -5,12 +5,8 @@ | ||
// .createSocket | ||
// .socket | ||
var sock = zmq.createSocket('req'); | ||
var sock = zmq.socket('req'); | ||
sock.type.should.equal('req'); | ||
sock.close.should.be.a('function'); | ||
// .socket | ||
zmq.socket.should.equal(zmq.createSocket); | ||
// options | ||
@@ -17,0 +13,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 3 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
84
1
65954
3
28
600