deprecationWarning.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import defined from "./defined.js";
  2. import DeveloperError from "./DeveloperError.js";
  3. import oneTimeWarning from "./oneTimeWarning.js";
  4. /**
  5. * Logs a deprecation message to the console. Use this function instead of
  6. * <code>console.log</code> directly since this does not log duplicate messages
  7. * unless it is called from multiple workers.
  8. *
  9. * @function deprecationWarning
  10. *
  11. * @param {String} identifier The unique identifier for this deprecated API.
  12. * @param {String} message The message to log to the console.
  13. *
  14. * @example
  15. * // Deprecated function or class
  16. * function Foo() {
  17. * deprecationWarning('Foo', 'Foo was deprecated in Cesium 1.01. It will be removed in 1.03. Use newFoo instead.');
  18. * // ...
  19. * }
  20. *
  21. * // Deprecated function
  22. * Bar.prototype.func = function() {
  23. * deprecationWarning('Bar.func', 'Bar.func() was deprecated in Cesium 1.01. It will be removed in 1.03. Use Bar.newFunc() instead.');
  24. * // ...
  25. * };
  26. *
  27. * // Deprecated property
  28. * Object.defineProperties(Bar.prototype, {
  29. * prop : {
  30. * get : function() {
  31. * deprecationWarning('Bar.prop', 'Bar.prop was deprecated in Cesium 1.01. It will be removed in 1.03. Use Bar.newProp instead.');
  32. * // ...
  33. * },
  34. * set : function(value) {
  35. * deprecationWarning('Bar.prop', 'Bar.prop was deprecated in Cesium 1.01. It will be removed in 1.03. Use Bar.newProp instead.');
  36. * // ...
  37. * }
  38. * }
  39. * });
  40. *
  41. * @private
  42. */
  43. function deprecationWarning(identifier, message) {
  44. //>>includeStart('debug', pragmas.debug);
  45. if (!defined(identifier) || !defined(message)) {
  46. throw new DeveloperError("identifier and message are required.");
  47. }
  48. //>>includeEnd('debug');
  49. oneTimeWarning(identifier, message);
  50. }
  51. export default deprecationWarning;