index.js (509B)
1 2 /** 3 * Module dependencies. 4 */ 5 6 var XHR = require('./polling-xhr'); 7 var JSONP = require('./polling-jsonp'); 8 9 /** 10 * Export transports. 11 */ 12 13 module.exports = exports = { 14 polling: polling, 15 websocket: require('./websocket') 16 }; 17 18 /** 19 * Export upgrades map. 20 */ 21 22 exports.polling.upgradesTo = ['websocket']; 23 24 /** 25 * Polling polymorphic constructor. 26 * 27 * @api private 28 */ 29 30 function polling (req) { 31 if ('string' === typeof req._query.j) { 32 return new JSONP(req); 33 } else { 34 return new XHR(req); 35 } 36 }