defaultValue-81eec7ed.js 2.0 KB

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