Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Unified Diff: remoting/webapp/base/js/base.js

Issue 1055313002: Added mock_xhr module w/ unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for review Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/base/js/base.js
diff --git a/remoting/webapp/base/js/base.js b/remoting/webapp/base/js/base.js
index 9257a8603ad4f4746c80d2eb5de6543223f9fde6..f34b2e24ec651557c427b65413744652acaf42f7 100644
--- a/remoting/webapp/base/js/base.js
+++ b/remoting/webapp/base/js/base.js
@@ -215,6 +215,28 @@ base.deepCopy = function(value) {
};
/**
+ * Returns a copy of the input object with all null/undefined fields
+ * removed. Returns an empty object for a null/undefined input.
+ *
+ * @param {Object<string,?T>|undefined} input
+ * @return {!Object<string,T>}
+ * @template T
+ */
+base.copyWithoutNullFields = function(input) {
+ /** @const {!Object} */
+ var result = {};
+ if (input) {
+ for (var field in input) {
+ var value = /** @type {*} */ (input[field]);
+ if (value != null) {
+ result[field] = value;
+ }
+ }
+ }
+ return result;
+};
+
+/**
* @type {boolean|undefined}
* @private
*/

Powered by Google App Engine
This is Rietveld 408576698