Skip to content

Commit

Permalink
Replace usages of goog.isFunction
Browse files Browse the repository at this point in the history
Refactor JavaScript code to use goog.functions.isFunction()
instead of goog.isFunction().

goog.isFunction() got deprecated and removed from the recent
versions of the Closure Library; for whatever reason, they decided to
add a synonym "goog.functions.isFunction".

This change contributes to the refactoring effort tracked by #264.
  • Loading branch information
emaxx-google committed Jul 28, 2021
1 parent db9a3f1 commit 5bc39da
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion common/js/src/container-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
goog.provide('GoogleSmartCard.ContainerHelpers');

goog.require('GoogleSmartCard.Logging');
goog.require('goog.functions');
goog.require('goog.object');

goog.scope(function() {
Expand Down Expand Up @@ -59,7 +60,7 @@ GSC.ContainerHelpers.substituteArrayBuffersRecursively = function(value) {
// Recursively process array items.
return value.map(substituteArrayBuffersRecursively);
}
if (goog.isObject(value) && !goog.isFunction(value) &&
if (goog.isObject(value) && !goog.functions.isFunction(value) &&
!ArrayBuffer.isView(value)) {
// This is a dictionary-like object; process it recursively.
return goog.object.map(value, substituteArrayBuffersRecursively);
Expand Down
3 changes: 2 additions & 1 deletion common/js/src/logging/debug-dump.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ goog.provide('GoogleSmartCard.DebugDump');

goog.require('goog.Disposable');
goog.require('goog.array');
goog.require('goog.functions');
goog.require('goog.iter');
goog.require('goog.json');
goog.require('goog.math');
Expand Down Expand Up @@ -213,7 +214,7 @@ function dump(value) {
return dumpString(value);
if (Array.isArray(value))
return dumpArray(value);
if (goog.isFunction(value))
if (goog.functions.isFunction(value))
return dumpFunction(value);
if (value instanceof ArrayBuffer)
return dumpArrayBuffer(value);
Expand Down
3 changes: 2 additions & 1 deletion common/js/src/messaging/mock-port.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ goog.provide('GoogleSmartCard.MockPort');
goog.require('GoogleSmartCard.Logging');
goog.require('goog.Disposable');
goog.require('goog.events.ListenerMap');
goog.require('goog.functions');
goog.require('goog.testing');

goog.setTestOnly();
Expand Down Expand Up @@ -157,7 +158,7 @@ MockPort.prototype.removeListener_ = function(type, callback) {
MockPort.prototype.getListeners_ = function(type) {
const result = [];
for (let listenerKey of this.listenerMap_.getListeners(type, false)) {
if (goog.isFunction(listenerKey.listener))
if (goog.functions.isFunction(listenerKey.listener))
result.push(listenerKey.listener);
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ goog.require('GoogleSmartCard.RequestReceiver');
goog.require('goog.Promise');
goog.require('goog.asserts');
goog.require('goog.array');
goog.require('goog.functions');
goog.require('goog.iter');
goog.require('goog.log.Logger');
goog.require('goog.messaging.AbstractChannel');
Expand Down Expand Up @@ -213,7 +214,7 @@ ChromeUsbBackend.prototype.processRequest_ = function(payload) {
*/
ChromeUsbBackend.prototype.getChromeUsbFunction_ = function(functionName) {
if (!goog.object.containsKey(chrome.usb, functionName) ||
!goog.isFunction(chrome.usb[functionName])) {
!goog.functions.isFunction(chrome.usb[functionName])) {
GSC.Logging.failWithLogger(
this.logger,
'Unknown chrome.usb API function requested: ' + functionName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ goog.require('GoogleSmartCard.RemoteCallMessage');
goog.require('GoogleSmartCard.RequestReceiver');
goog.require('goog.Promise');
goog.require('goog.Timer');
goog.require('goog.functions');
goog.require('goog.log.Logger');
goog.require('goog.messaging.AbstractChannel');
goog.require('goog.object');
Expand Down Expand Up @@ -352,7 +353,7 @@ NaclClientBackend.prototype.apiMethodRejectedCallback_ = function(
NaclClientBackend.prototype.getApiMethod_ = function(methodName) {
GSC.Logging.checkWithLogger(this.logger, this.api_);
if (!goog.object.containsKey(this.api_, methodName) ||
!goog.isFunction(this.api_[methodName])) {
!goog.functions.isFunction(this.api_[methodName])) {
GSC.Logging.failWithLogger(
this.logger,
'Unknown PC/SC-Lite Client API method requested: ' + methodName);
Expand Down

0 comments on commit 5bc39da

Please sign in to comment.