-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
priorities.ts
55 lines (47 loc) · 1.29 KB
/
priorities.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
/**
* @module utils/priorities
*/
/**
* String representing a priority value.
*/
export type PriorityString = 'highest' | 'high' | 'normal' | 'low' | 'lowest' | number;
// This interface exists to make our API pages more readable.
/**
* Provides group of constants to use instead of hardcoding numeric priority values.
*/
export interface PrioritiesType {
/**
* Converts a string with priority name to it's numeric value. If `Number` is given, it just returns it.
*
* @param priority Priority to convert.
* @returns Converted priority.
*/
get( priority?: PriorityString ): number;
readonly highest: number;
readonly high: number;
readonly normal: number;
readonly low: number;
readonly lowest: number;
}
/**
* Provides group of constants to use instead of hardcoding numeric priority values.
*/
const priorities: PrioritiesType = {
get( priority: PriorityString = 'normal' ): number {
if ( typeof priority != 'number' ) {
return this[ priority ] || this.normal;
} else {
return priority;
}
},
highest: 100000,
high: 1000,
normal: 0,
low: -1000,
lowest: -100000
};
export default priorities;