now works browserify, considering publishing to npm #76

Closed
wants to merge 5 commits into
from
View
@@ -0,0 +1,3 @@
+.testling_env.sh
+bin/.testling_env.sh
+tests
View
@@ -1,5 +1,5 @@
// Public object
-SockJS = (function(){
+var SockJS = (function(){
var _document = document;
var _window = window;
var utils = {};
@@ -35,3 +35,7 @@ if ('_sockjs_onload' in window) setTimeout(_sockjs_onload, 1);
if (typeof define === 'function' && define.amd) {
define('sockjs', [], function(){return SockJS;});
}
+
+if (typeof module === 'object' && module && module.exports) {
+ module.exports = SockJS;
+}
View
@@ -7,6 +7,11 @@
*/
var SockJS = function(url, dep_protocols_whitelist, options) {
+ if (this === window) {
+ // makes `new` optional
+ return new SockJS(url, dep_protocols_whitelist, options);
+ }
+
var that = this, protocols_whitelist;
that._options = {devel: false, debug: false, protocols_whitelist: [],
info: undefined, rtt: undefined};
View
@@ -14,5 +14,5 @@
"optparse" : "1.0.3",
"node-static" : "0.5.9"
},
- "private": true
+ "main": "sockjs.js"
}