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. | |
23 * @return {boolean} | 22 * @return {boolean} |
24 */ | 23 */ |
25 var isBoolean = function(value, opt_allowUndefined) { | 24 var isBoolean = function(value) { |
26 if (opt_allowUndefined && value === 'undefined') { | |
27 return true; | |
28 } | |
29 return typeof value == 'boolean'; | 25 return typeof value == 'boolean'; |
30 }; | 26 }; |
31 | 27 |
32 /** | 28 /** |
33 * @param {*} value | 29 * @param {*} value |
34 * @param {boolean=} opt_allowUndefined True to accept undefined. | |
35 * @return {boolean} | 30 * @return {boolean} |
36 */ | 31 */ |
37 var isNumber = function(value, opt_allowUndefined) { | 32 var isNumber = function(value) { |
38 if (opt_allowUndefined && value === 'undefined') { | |
39 return true; | |
40 } | |
41 return typeof value == 'number'; | 33 return typeof value == 'number'; |
42 }; | 34 }; |
43 | 35 |
44 /** | 36 /** |
45 * @param {*} value | 37 * @param {*} value |
46 * @return {boolean} | 38 * @return {boolean} |
47 */ | 39 */ |
48 var isObject = function(value) { | 40 var isObject = function(value) { |
49 return value != null && typeof value == 'object' && !Array.isArray(value); | 41 return value != null && typeof value == 'object' && !Array.isArray(value); |
50 }; | 42 }; |
51 | 43 |
52 /** | 44 /** |
53 * @param {*} value | 45 * @param {*} value |
54 * @param {boolean=} opt_allowUndefined True to accept undefined. | |
55 * @return {boolean} | 46 * @return {boolean} |
56 */ | 47 */ |
57 var isString = function(value, opt_allowUndefined) { | 48 var isString = function(value) { |
58 if (opt_allowUndefined && value === 'undefined') { | |
59 return true; | |
60 } | |
61 return typeof value == 'string'; | 49 return typeof value == 'string'; |
62 }; | 50 }; |
63 | 51 |
64 /** | 52 /** |
65 * @param {*} value | 53 * @param {*} value |
66 * @return {string} | 54 * @return {string} |
67 */ | 55 */ |
68 var jsonTypeOf = function(value) { | 56 var jsonTypeOf = function(value) { |
69 if (typeof value == 'object') { | 57 if (typeof value == 'object') { |
70 if (value === null) { | 58 if (value === null) { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 * If the string cannot be parsed, or does not result in an object, then an | 239 * If the string cannot be parsed, or does not result in an object, then an |
252 * exception will be thrown. | 240 * exception will be thrown. |
253 * | 241 * |
254 * @param {string} jsonString The JSON string to parse. | 242 * @param {string} jsonString The JSON string to parse. |
255 * @return {Object} The JSON object created from the |jsonString|. | 243 * @return {Object} The JSON object created from the |jsonString|. |
256 */ | 244 */ |
257 base.getJsonObjectFromString = function(jsonString) { | 245 base.getJsonObjectFromString = function(jsonString) { |
258 return base.assertObject(base.jsonParseSafe(jsonString)); | 246 return base.assertObject(base.jsonParseSafe(jsonString)); |
259 }; | 247 }; |
260 | 248 |
261 })(); | 249 })(); |
OLD | NEW |