From d3365e24578b0a44f6a550ec00883aed2b18b666 Mon Sep 17 00:00:00 2001 From: Michael Schoonmaker Date: Thu, 7 Feb 2013 17:15:15 -0800 Subject: [PATCH] Type may now be either a String or a Number. This is what the docstring claims, and is now correct. --- lib/index.js | 3 ++- test/test.socket.js | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 1ef5508..2b2a688 100644 --- a/lib/index.js +++ b/lib/index.js @@ -99,7 +99,8 @@ function gcWrap (self) {} function Socket(type) { this.type = type; - this._zmq = new zmq.Socket(defaultContext(), types[type]); + this._type = typeof type === 'number' ? type : types[type]; + this._zmq = new zmq.Socket(defaultContext(), this._type); this._zmq.onReady = this._flush.bind(this); this._outgoing = []; this._shouldFlush = true; diff --git a/test/test.socket.js b/test/test.socket.js index 60b110e..bae1b7d 100644 --- a/test/test.socket.js +++ b/test/test.socket.js @@ -11,6 +11,11 @@ zmq.createSocket.should.equal(zmq.socket); var sock = zmq.socket('req'); sock.type.should.equal('req'); sock.close.should.be.a('function'); +sock.close(); + +sock = zmq.socket(zmq.ZMQ_REQ); +sock.type.should.equal(zmq.ZMQ_REQ); +sock.close.should.be.a('function'); // setsockopt