Skip to content

Commit d2eda13

Browse files
authored
Change goog.now() to Date.now() (#4623)
1 parent 045e4b5 commit d2eda13

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

packages/auth/src/autheventmanager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ fireauth.AuthEventManager.prototype.unsubscribe = function(handler) {
388388
fireauth.AuthEventManager.prototype.hasProcessedAuthEvent_ =
389389
function(authEvent) {
390390
// Prevent duplicate event tracker from growing too large.
391-
if (goog.now() - this.lastProcessedEventTime_ >=
391+
if (Date.now() - this.lastProcessedEventTime_ >=
392392
fireauth.AuthEventManager.EVENT_DUPLICATION_CACHE_DURATION) {
393393
this.processedEvents_ = {};
394394
this.lastProcessedEventTime_ = 0;
@@ -417,7 +417,7 @@ fireauth.AuthEventManager.prototype.saveProcessedAuthEvent_ =
417417
this.processedEvents_[
418418
/** @type {string} */ (authEvent.getUid())] = true;
419419
// Save last processing time.
420-
this.lastProcessedEventTime_ = goog.now();
420+
this.lastProcessedEventTime_ = Date.now();
421421
}
422422
};
423423

packages/auth/src/cacherequest.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -42,7 +42,7 @@ fireauth.CacheRequest = function() {
4242
/** @private {?goog.Promise} The cached returned promise result. */
4343
this.cachedResult_ = null;
4444
/** @private {number} The expiration timestamp of the cached result. */
45-
this.expirationTime_ = goog.now();
45+
this.expirationTime_ = Date.now();
4646
/** @private {number} The time to live from the caching point in time. */
4747
this.ttl_ = 0;
4848
/** @private {boolean} Whether to cache errors too. */
@@ -62,7 +62,7 @@ fireauth.CacheRequest.prototype.cache =
6262
this.func_ = func;
6363
this.self_ = self;
6464
this.arguments_ = args;
65-
this.expirationTime_ = goog.now();
65+
this.expirationTime_ = Date.now();
6666
this.ttl_ = ttl;
6767
this.cacheErrors_ = !!opt_cacheErrors;
6868

@@ -79,9 +79,9 @@ fireauth.CacheRequest.prototype.run = function() {
7979
throw new Error('No available configuration cached!');
8080
}
8181
// If the result is not cached or the cache result is outdated.
82-
if (!this.cachedResult_ || goog.now() >= this.expirationTime_) {
82+
if (!this.cachedResult_ || Date.now() >= this.expirationTime_) {
8383
// Set expiration of current request.
84-
this.expirationTime_ = goog.now() + this.ttl_;
84+
this.expirationTime_ = Date.now() + this.ttl_;
8585
// Get new result and cache it.
8686
this.cachedResult_ =
8787
this.func_.apply(this.self_, this.arguments_).then(function(result) {
@@ -93,7 +93,7 @@ fireauth.CacheRequest.prototype.run = function() {
9393
if (!self.cacheErrors_) {
9494
// Do not cache errors if errors are not to be cached.
9595
// This will bust the cached result. Otherwise the error is cached.
96-
self.expirationTime_ = goog.now();
96+
self.expirationTime_ = Date.now();
9797
}
9898
// Throw the returned error.
9999
throw error;
@@ -108,5 +108,5 @@ fireauth.CacheRequest.prototype.run = function() {
108108
fireauth.CacheRequest.prototype.purge = function() {
109109
// Purge the cached results.
110110
this.cachedResult_ = null;
111-
this.expirationTime_ = goog.now();
111+
this.expirationTime_ = Date.now();
112112
};

packages/auth/src/rpchandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ fireauth.RpcHandler.prototype.requestAuthEndpoint_ = function(
905905
uri.setParameterValue('key', this.getApiKey());
906906
// Check whether to append cachebuster to request.
907907
if (opt_cachebuster) {
908-
uri.setParameterValue('cb', goog.now().toString());
908+
uri.setParameterValue('cb', Date.now().toString());
909909
}
910910
// Firebase allows GET endpoints.
911911
var isGet = httpMethod == fireauth.RpcHandler.HttpMethod.GET;

packages/auth/test/proactiverefresh_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -71,7 +71,7 @@ function setUp() {
7171
// Operation to practively refresh.
7272
operation = goog.testing.recordFunction(function() {
7373
// Record last run time.
74-
lastTimestamp = goog.now();
74+
lastTimestamp = Date.now();
7575
if (!forceRetryError) {
7676
// Do not force error retry. Resolve successfully.
7777
return goog.Promise.resolve();
@@ -84,7 +84,7 @@ function setUp() {
8484
// Operation which throws an unrecoverable error.
8585
unrecoverableOperation = goog.testing.recordFunction(function() {
8686
// Record last run time.
87-
lastTimestamp = goog.now();
87+
lastTimestamp = Date.now();
8888
// Throw unrecoverable error.
8989
return goog.Promise.reject(
9090
new fireauth.AuthError(fireauth.authenum.Error.INTERNAL_ERROR));

0 commit comments

Comments
 (0)