defaultValue-a6eb9f34.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * @license
  3. * Cesium - https://github.com/CesiumGS/cesium
  4. * Version 1.97
  5. *
  6. * Copyright 2011-2022 Cesium Contributors
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. *
  20. * Columbus View (Pat. Pend.)
  21. *
  22. * Portions licensed separately.
  23. * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
  24. */
  25. define(['exports'], (function (exports) { 'use strict';
  26. /**
  27. * @function
  28. *
  29. * @param {*} value The object.
  30. * @returns {Boolean} Returns true if the object is defined, returns false otherwise.
  31. *
  32. * @example
  33. * if (Cesium.defined(positions)) {
  34. * doSomething();
  35. * } else {
  36. * doSomethingElse();
  37. * }
  38. */
  39. function defined(value) {
  40. return value !== undefined && value !== null;
  41. }
  42. /**
  43. * Returns the first parameter if not undefined, otherwise the second parameter.
  44. * Useful for setting a default value for a parameter.
  45. *
  46. * @function
  47. *
  48. * @param {*} a
  49. * @param {*} b
  50. * @returns {*} Returns the first parameter if not undefined, otherwise the second parameter.
  51. *
  52. * @example
  53. * param = Cesium.defaultValue(param, 'default');
  54. */
  55. function defaultValue(a, b) {
  56. if (a !== undefined && a !== null) {
  57. return a;
  58. }
  59. return b;
  60. }
  61. /**
  62. * A frozen empty object that can be used as the default value for options passed as
  63. * an object literal.
  64. * @type {Object}
  65. * @memberof defaultValue
  66. */
  67. defaultValue.EMPTY_OBJECT = Object.freeze({});
  68. exports.defaultValue = defaultValue;
  69. exports.defined = defined;
  70. }));