[Pkg-javascript-commits] [sockjs-client] 83/350: Remove unnecessary utils.delay function
tonnerre at ancient-solutions.com
tonnerre at ancient-solutions.com
Fri Aug 5 01:03:45 UTC 2016
This is an automated email from the git hooks/post-receive script.
tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.
commit aabef5668921ab3dc9cd604e03457bb3e6bc60e3
Author: Bryce Kahle <bkahle at gmail.com>
Date: Sun Aug 24 23:52:42 2014 -0400
Remove unnecessary utils.delay function
---
lib/buffered-sender.js | 6 ++----
lib/info-receiver-fake.js | 5 ++---
lib/info-receiver.js | 8 ++++----
lib/sockjs.js | 6 +++---
lib/trans-jsonp-polling.js | 4 ++--
lib/trans-receiver-eventsource.js | 5 ++---
lib/utils.js | 9 ---------
lib/xdr.js | 2 +-
lib/xhr-cors.js | 3 +--
lib/xhr-local.js | 5 ++---
10 files changed, 19 insertions(+), 34 deletions(-)
diff --git a/lib/buffered-sender.js b/lib/buffered-sender.js
index 20e2572..3a4a1b5 100644
--- a/lib/buffered-sender.js
+++ b/lib/buffered-sender.js
@@ -7,8 +7,6 @@
* ***** END LICENSE BLOCK *****
*/
-var utils = require('./utils');
-
function BufferedSender() {}
BufferedSender.prototype.send_constructor = function(sender) {
var that = this;
@@ -38,10 +36,10 @@ BufferedSender.prototype.send_schedule_wait = function() {
that.send_stop = null;
clearTimeout(tref);
};
- tref = utils.delay(25, function() {
+ tref = setTimeout(function() {
that.send_stop = null;
that.send_schedule();
- });
+ }, 25);
};
BufferedSender.prototype.send_schedule = function() {
diff --git a/lib/info-receiver-fake.js b/lib/info-receiver-fake.js
index 84fd6fc..2c48efc 100644
--- a/lib/info-receiver-fake.js
+++ b/lib/info-receiver-fake.js
@@ -9,7 +9,6 @@
var EventEmitter = require('events').EventEmitter
, util = require('util')
- , utils = require('./utils')
;
var InfoReceiverFake = function() {
@@ -17,9 +16,9 @@ var InfoReceiverFake = function() {
// data, for example for IE7. But we want to run JSONP, so let's
// fake the response, with rtt=2s (rto=6s).
var that = this;
- utils.delay(function() {
+ setTimeout(function() {
that.emit('finish', {}, 2000);
- });
+ }, 0);
};
util.inherits(InfoReceiverFake, EventEmitter);
diff --git a/lib/info-receiver.js b/lib/info-receiver.js
index cc7f230..369db6e 100644
--- a/lib/info-receiver.js
+++ b/lib/info-receiver.js
@@ -10,12 +10,13 @@
var EventEmitter = require('events').EventEmitter
, util = require('util')
, JSON3 = require('json3')
- , utils = require('./utils')
;
function InfoReceiver(base_url, AjaxObject) {
var that = this;
- utils.delay(function(){that.doXhr(base_url, AjaxObject);});
+ setTimeout(function(){
+ that.doXhr(base_url, AjaxObject);
+ }, 0);
}
util.inherits(InfoReceiver, EventEmitter);
@@ -25,8 +26,7 @@ InfoReceiver.prototype.doXhr = function(base_url, AjaxObject) {
var t0 = (new Date()).getTime();
var xo = new AjaxObject('GET', base_url + '/info');
- var tref = utils.delay(8000,
- function(){xo.ontimeout();});
+ var tref = setTimeout(function(){xo.ontimeout();}, 8000);
xo.on('finish', function(status, text) {
clearTimeout(tref);
diff --git a/lib/sockjs.js b/lib/sockjs.js
index a49ccf0..f48370b 100644
--- a/lib/sockjs.js
+++ b/lib/sockjs.js
@@ -141,9 +141,9 @@ SockJS.prototype._didClose = function(code, reason, force) {
}
that.readyState = SockJS.CLOSED;
- utils.delay(function() {
+ setTimeout(function() {
that.dispatchEvent(close_event);
- });
+ }, 0);
};
SockJS.prototype._didMessage = function(data) {
@@ -216,7 +216,7 @@ SockJS.prototype._try_next_protocol = function(close_event) {
var roundTrips = Protocol.roundTrips || 1;
var to = ((that._rto || 0) * roundTrips) || 5000;
- that._transport_tref = utils.delay(to, timeoutFunction);
+ that._transport_tref = setTimeout(timeoutFunction, to);
var connid = utils.random_string(8);
var trans_url = that._base_url + '/' + that._server + '/' + connid;
diff --git a/lib/trans-jsonp-polling.js b/lib/trans-jsonp-polling.js
index ede68a2..0dc55c8 100644
--- a/lib/trans-jsonp-polling.js
+++ b/lib/trans-jsonp-polling.js
@@ -152,10 +152,10 @@ function jsonPGenericSender(url, payload, callback) {
iframe.onreadystatechange = iframe.onerror = iframe.onload = null;
// Opera mini doesn't like if we GC iframe
// immediately, thus this timeout.
- utils.delay(500, function() {
+ setTimeout(function() {
iframe.parentNode.removeChild(iframe);
iframe = null;
- });
+ }, 500);
area.value = '';
// It is not possible to detect if the iframe succeeded or
// failed to submit our form.
diff --git a/lib/trans-receiver-eventsource.js b/lib/trans-receiver-eventsource.js
index eee45c9..2f005cf 100644
--- a/lib/trans-receiver-eventsource.js
+++ b/lib/trans-receiver-eventsource.js
@@ -9,7 +9,6 @@
var SimpleEvent = require('./simpleevent');
var REventTarget = require('./reventtarget');
-var utils = require('./utils');
function EventSourceReceiver(url) {
var that = this;
@@ -30,9 +29,9 @@ function EventSourceReceiver(url) {
// Safari and chrome < 15 crash if we close window before
// waiting for ES cleanup. See:
// https://code.google.com/p/chromium/issues/detail?id=89155
- utils.delay(200, function() {
+ setTimeout(function() {
that.dispatchEvent(new SimpleEvent('close', {reason: reason}));
- });
+ }, 200);
};
}
diff --git a/lib/utils.js b/lib/utils.js
index d56d516..aef8451 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -208,15 +208,6 @@ utils.isArray = Array.isArray || function(arg) {
return Object.prototype.toString.call(arg) === '[object Array]';
};
-utils.delay = function(t, fun) {
- if(typeof t === 'function') {
- fun = t;
- t = 0;
- }
- return setTimeout(fun, t);
-};
-
-
// Chars worth escaping, as defined by Douglas Crockford:
// https://github.com/douglascrockford/JSON-js/blob/47a9882cddeb1e8529e07af9736218075372b8ac/json2.js#L196
var json_escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
diff --git a/lib/xdr.js b/lib/xdr.js
index bf1c527..f684e0a 100644
--- a/lib/xdr.js
+++ b/lib/xdr.js
@@ -11,7 +11,7 @@ var EventEmitter = require('events').EventEmitter
function XDRObject(method, url, payload) {
var that = this;
- utils.delay(function(){that._start(method, url, payload);});
+ setTimeout(function(){that._start(method, url, payload);}, 0);
}
util.inherits(XDRObject, EventEmitter);
diff --git a/lib/xhr-cors.js b/lib/xhr-cors.js
index c34dd77..b9fa93b 100644
--- a/lib/xhr-cors.js
+++ b/lib/xhr-cors.js
@@ -1,11 +1,10 @@
'use strict';
var AbstractXHRObject = require('./abstract-xhr');
-var utils = require('./utils');
function XHRCorsObject() {
var that = this, args = arguments;
- utils.delay(function(){that._start.apply(that, args);});
+ setTimeout(function(){that._start.apply(that, args);}, 0);
}
XHRCorsObject.prototype = new AbstractXHRObject();
diff --git a/lib/xhr-local.js b/lib/xhr-local.js
index a729a9b..2854d94 100644
--- a/lib/xhr-local.js
+++ b/lib/xhr-local.js
@@ -1,15 +1,14 @@
'use strict';
-var utils = require('./utils');
var AbstractXHRObject = require('./abstract-xhr');
function XHRLocalObject(method, url, payload) {
var that = this;
- utils.delay(function(){
+ setTimeout(function(){
that._start(method, url, payload, {
no_credentials: true
});
- });
+ }, 0);
}
XHRLocalObject.prototype = new AbstractXHRObject();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git
More information about the Pkg-javascript-commits
mailing list