8
0

priorities.js 874 B

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