priorities.js 1004 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /**
  6. * @module utils/priorities
  7. */
  8. /**
  9. * String representing a priority value.
  10. *
  11. * @typedef {'highest'|'high'|'normal'|'low'|'lowest'} module:utils/priorities~PriorityString
  12. */
  13. /**
  14. * Provides group of constants to use instead of hardcoding numeric priority values.
  15. *
  16. * @namespace
  17. */
  18. const priorities = {
  19. /**
  20. * Converts a string with priority name to it's numeric value. If `Number` is given, it just returns it.
  21. *
  22. * @static
  23. * @param {module:utils/priorities~PriorityString|Number} priority Priority to convert.
  24. * @returns {Number} Converted priority.
  25. */
  26. get( priority ) {
  27. if ( typeof priority != 'number' ) {
  28. return this[ priority ] || this.normal;
  29. } else {
  30. return priority;
  31. }
  32. },
  33. highest: 100000,
  34. high: 1000,
  35. normal: 0,
  36. low: -1000,
  37. lowest: -100000
  38. };
  39. export default priorities;