Chromium Code Reviews| Index: remoting/webapp/base/js/typecheck.js |
| diff --git a/remoting/webapp/base/js/typecheck.js b/remoting/webapp/base/js/typecheck.js |
| index 10e1959dd7b33fec2055708c5b0f5329eb0c5a03..04f83cd728c6c6ccb4a2753a14779206b9470f46 100644 |
| --- a/remoting/webapp/base/js/typecheck.js |
| +++ b/remoting/webapp/base/js/typecheck.js |
| @@ -19,17 +19,25 @@ var isArray = function(value) { |
| /** |
| * @param {*} value |
| + * @param {boolean=} allowUndefined True to allow undefined as a valid boolean. |
|
Jamie
2015/05/13 23:43:18
Optional parameters should be prefixed with opt_
garykac
2015/05/15 01:29:36
Done.
|
| * @return {boolean} |
| */ |
| -var isBoolean = function(value) { |
| +var isBoolean = function(value, allowUndefined) { |
| + if (allowUndefined && typeof value === 'undefined') { |
|
Jamie
2015/05/13 23:43:18
No need for typeof here; "value === undefined" is
garykac
2015/05/15 01:29:36
Done.
|
| + return true; |
| + } |
| return typeof value == 'boolean'; |
| }; |
| /** |
| * @param {*} value |
| + * @param {boolean=} allowUndefined True to allow undefined as a valid number. |
|
Jamie
2015/05/13 23:43:18
You haven't added allowUndefined to the parameter
garykac
2015/05/15 01:29:36
Fixed.
|
| * @return {boolean} |
| */ |
| var isNumber = function(value) { |
| + if (allowUndefined && typeof value === 'undefined') { |
| + return true; |
| + } |
| return typeof value == 'number'; |
| }; |
| @@ -43,9 +51,13 @@ var isObject = function(value) { |
| /** |
| * @param {*} value |
| + * @param {boolean=} allowUndefined True to allow undefined as a valid string. |
| * @return {boolean} |
| */ |
| var isString = function(value) { |
| + if (allowUndefined && typeof value === 'undefined') { |
| + return true; |
| + } |
| return typeof value == 'string'; |
| }; |
| @@ -246,4 +258,4 @@ base.getJsonObjectFromString = function(jsonString) { |
| return base.assertObject(base.jsonParseSafe(jsonString)); |
| }; |
| -})(); |
| +})(); |