-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from ibc/master
W3CWebSocket: Use just one or two arguments (fixes #173)
- Loading branch information
Showing
2 changed files
with
22 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,32 @@ | ||
var _global = (function() { return this; })(); | ||
var nativeWebSocket = _global.WebSocket || _global.MozWebSocket; | ||
|
||
|
||
/** | ||
* W3CWebSocket constructor. | ||
* Expose a W3C WebSocket class with just one or two arguments. | ||
*/ | ||
var W3CWebSocket = _global.WebSocket || _global.MozWebSocket; | ||
function W3CWebSocket(uri, protocols) { | ||
var instance; | ||
|
||
if (protocols) { | ||
instance = new nativeWebSocket(uri, protocols); | ||
} | ||
else { | ||
instance = new nativeWebSocket(uri); | ||
} | ||
|
||
return instance; | ||
} | ||
|
||
if (nativeWebSocket) { | ||
W3CWebSocket.prototype = nativeWebSocket.prototype; | ||
} | ||
|
||
|
||
/** | ||
* Module exports. | ||
*/ | ||
module.exports = { | ||
'w3cwebsocket' : W3CWebSocket ? W3CWebSocket : null, | ||
'w3cwebsocket' : nativeWebSocket ? W3CWebSocket : null, | ||
'version' : require('./version') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5a86cd6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Let me know when 1.0.14 will be released as I need to update some dependencies :)
5a86cd6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5a86cd6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, don't worry! Please take your time.
Thanks a lot.