| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 /** @suppress {duplicate} */ | 6 /** @suppress {duplicate} */ |
| 7 var remoting = remoting || {}; | 7 var remoting = remoting || {}; |
| 8 | 8 |
| 9 (function() { | 9 (function() { |
| 10 'use strict'; | 10 'use strict'; |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * @param {*} value | 13 * @param {*} value |
| 14 * @return {boolean} | 14 * @return {boolean} |
| 15 */ | 15 */ |
| 16 var isArray = function(value) { | 16 var isArray = function(value) { |
| 17 return Array.isArray(value); | 17 return Array.isArray(value); |
| 18 }; | 18 }; |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * @param {*} value | 21 * @param {*} value |
| 22 * @param {boolean=} opt_allowUndefined True to accept undefined. |
| 22 * @return {boolean} | 23 * @return {boolean} |
| 23 */ | 24 */ |
| 24 var isBoolean = function(value) { | 25 var isBoolean = function(value, opt_allowUndefined) { |
| 26 if (opt_allowUndefined && value === 'undefined') { |
| 27 return true; |
| 28 } |
| 25 return typeof value == 'boolean'; | 29 return typeof value == 'boolean'; |
| 26 }; | 30 }; |
| 27 | 31 |
| 28 /** | 32 /** |
| 29 * @param {*} value | 33 * @param {*} value |
| 34 * @param {boolean=} opt_allowUndefined True to accept undefined. |
| 30 * @return {boolean} | 35 * @return {boolean} |
| 31 */ | 36 */ |
| 32 var isNumber = function(value) { | 37 var isNumber = function(value, opt_allowUndefined) { |
| 38 if (opt_allowUndefined && value === 'undefined') { |
| 39 return true; |
| 40 } |
| 33 return typeof value == 'number'; | 41 return typeof value == 'number'; |
| 34 }; | 42 }; |
| 35 | 43 |
| 36 /** | 44 /** |
| 37 * @param {*} value | 45 * @param {*} value |
| 38 * @return {boolean} | 46 * @return {boolean} |
| 39 */ | 47 */ |
| 40 var isObject = function(value) { | 48 var isObject = function(value) { |
| 41 return value != null && typeof value == 'object' && !Array.isArray(value); | 49 return value != null && typeof value == 'object' && !Array.isArray(value); |
| 42 }; | 50 }; |
| 43 | 51 |
| 44 /** | 52 /** |
| 45 * @param {*} value | 53 * @param {*} value |
| 54 * @param {boolean=} opt_allowUndefined True to accept undefined. |
| 46 * @return {boolean} | 55 * @return {boolean} |
| 47 */ | 56 */ |
| 48 var isString = function(value) { | 57 var isString = function(value, opt_allowUndefined) { |
| 58 if (opt_allowUndefined && value === 'undefined') { |
| 59 return true; |
| 60 } |
| 49 return typeof value == 'string'; | 61 return typeof value == 'string'; |
| 50 }; | 62 }; |
| 51 | 63 |
| 52 /** | 64 /** |
| 53 * @param {*} value | 65 * @param {*} value |
| 54 * @return {string} | 66 * @return {string} |
| 55 */ | 67 */ |
| 56 var jsonTypeOf = function(value) { | 68 var jsonTypeOf = function(value) { |
| 57 if (typeof value == 'object') { | 69 if (typeof value == 'object') { |
| 58 if (value === null) { | 70 if (value === null) { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 * If the string cannot be parsed, or does not result in an object, then an | 251 * If the string cannot be parsed, or does not result in an object, then an |
| 240 * exception will be thrown. | 252 * exception will be thrown. |
| 241 * | 253 * |
| 242 * @param {string} jsonString The JSON string to parse. | 254 * @param {string} jsonString The JSON string to parse. |
| 243 * @return {Object} The JSON object created from the |jsonString|. | 255 * @return {Object} The JSON object created from the |jsonString|. |
| 244 */ | 256 */ |
| 245 base.getJsonObjectFromString = function(jsonString) { | 257 base.getJsonObjectFromString = function(jsonString) { |
| 246 return base.assertObject(base.jsonParseSafe(jsonString)); | 258 return base.assertObject(base.jsonParseSafe(jsonString)); |
| 247 }; | 259 }; |
| 248 | 260 |
| 249 })(); | 261 })(); |
| OLD | NEW |