[Pkg-javascript-commits] [sockjs-client] 208/350: Remove Date.now() shim

tonnerre at ancient-solutions.com tonnerre at ancient-solutions.com
Fri Aug 5 01:04:22 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 b1a7ba4b1a677cfe44a7bcd8ab42d2445bb68ff2
Author: Bryce Kahle <bkahle at gmail.com>
Date:   Mon Oct 20 19:08:41 2014 -0400

    Remove Date.now() shim
---
 lib/event/event.js                    |  2 +-
 lib/info-ajax.js                      |  4 ++--
 lib/shims.js                          | 13 -------------
 lib/transport/browser/abstract-xhr.js |  2 +-
 lib/transport/sender/xdr.js           |  3 ++-
 5 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/lib/event/event.js b/lib/event/event.js
index d235f73..0d451de 100644
--- a/lib/event/event.js
+++ b/lib/event/event.js
@@ -8,7 +8,7 @@ Event.prototype.initEvent = function(eventType, canBubble, cancelable) {
   this.type = eventType;
   this.bubbles = canBubble;
   this.cancelable = cancelable;
-  this.timeStamp = Date.now();
+  this.timeStamp = +new Date();
   return this;
 };
 
diff --git a/lib/info-ajax.js b/lib/info-ajax.js
index c97a948..2610ea8 100644
--- a/lib/info-ajax.js
+++ b/lib/info-ajax.js
@@ -10,13 +10,13 @@ function InfoAjax(url, AjaxObject) {
   EventEmitter.call(this);
 
   var self = this;
-  var t0 = Date.now();
+  var t0 = +new Date();
   this.xo = new AjaxObject('GET', url);
 
   this.xo.once('finish', function(status, text) {
     var info, rtt;
     if (status === 200) {
-      rtt = Date.now() - t0;
+      rtt = (+new Date()) - t0;
       if (text) {
         try {
           info = JSON3.parse(text);
diff --git a/lib/shims.js b/lib/shims.js
index d9b81b5..477cfa9 100644
--- a/lib/shims.js
+++ b/lib/shims.js
@@ -315,19 +315,6 @@ defineProperties(ArrayPrototype, {
 }, hasFirefox2IndexOfBug);
 
 //
-// Date
-// ====
-//
-
-// ES5 15.9.4.4
-// http://es5.github.com/#x15.9.4.4
-if (!Date.now) {
-    Date.now = function now() {
-        return new Date().getTime();
-    };
-}
-
-//
 // String
 // ======
 //
diff --git a/lib/transport/browser/abstract-xhr.js b/lib/transport/browser/abstract-xhr.js
index 86912db..90fd256 100644
--- a/lib/transport/browser/abstract-xhr.js
+++ b/lib/transport/browser/abstract-xhr.js
@@ -29,7 +29,7 @@ function AbstractXHRObject(method, url, payload, opts) {
   }
 
   // several browsers cache POSTs
-  url = urlUtils.addQuery(url, 't=' + Date.now());
+  url = urlUtils.addQuery(url, 't=' + (+new Date()));
 
   // Explorer tends to keep connection open, even after the
   // tab gets closed: http://bugs.jquery.com/ticket/5280
diff --git a/lib/transport/sender/xdr.js b/lib/transport/sender/xdr.js
index fb0da16..32f4c52 100644
--- a/lib/transport/sender/xdr.js
+++ b/lib/transport/sender/xdr.js
@@ -4,6 +4,7 @@ var EventEmitter = require('events').EventEmitter
   , inherits = require('inherits')
   , eventUtils = require('../../utils/event')
   , browser = require('../../utils/browser')
+  , urlUtils = require('../../utils/url')
   ;
 
 var debug = function() {};
@@ -32,7 +33,7 @@ XDRObject.prototype._start = function(method, url, payload) {
   var self = this;
   var xdr = new global.XDomainRequest();
   // IE caches even POSTs
-  url += ((url.indexOf('?') === -1) ? '?' : '&') + 't=' + Date.now();
+  url += urlUtils.addQuery('t=' + (+new Date()));
 
   xdr.onerror = function() {
     debug('onerror');

-- 
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