Skip to content

Commit

Permalink
constructor supports options dictionary (fix #6)
Browse files Browse the repository at this point in the history
  • Loading branch information
feross committed Jul 21, 2015
1 parent 599e122 commit 4aeefcd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Expand Up @@ -90,11 +90,11 @@ inherits(Socket, EventEmitter)
* - exception Error object
* Emitted when an error occurs.
*/
function Socket (type, listener) {
function Socket (options, listener) {
var self = this
EventEmitter.call(self)

if (type !== 'udp4') throw new Error('Bad socket type specified. Valid types are: udp4')
if (typeof options === 'string') options = { type: options }
if (options.type !== 'udp4') throw new Error('Bad socket type specified. Valid types are: udp4')

if (typeof listener === 'function') self.on('message', listener)

Expand Down

0 comments on commit 4aeefcd

Please sign in to comment.