-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.d.ts
57 lines (51 loc) · 2.76 KB
/
index.d.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
56
57
// Types & Classes
export type SpecificityArray = [number, number, number];
export type SpecificityObject = { a: number; b: number; c: number };
export default class Specificity {
static calculate(selector: string | CSSTreeAST): Array<Specificity>;
static compare(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): number;
static equals(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
static lessThan(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
static greaterThan(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
static min(...specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
static max(...specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
static sortAsc(...specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
static sortDesc(...specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
constructor(value: SpecificityObject, selector?: any);
value: SpecificityObject;
selector: string | CSSTreeAST;
set a(arg: number);
get a(): number;
set b(arg: number);
get b(): number;
set c(arg: number);
get c(): number;
selectorString(): string;
toObject(): SpecificityObject;
toArray(): SpecificityArray;
toString(): string;
toJSON(): {
selector: string;
asObject: SpecificityObject;
asArray: SpecificityArray;
asString: string;
};
isEqualTo(otherSpecificity: SpecificityInstanceOrObject): boolean;
isGreaterThan(otherSpecificity: SpecificityInstanceOrObject): boolean;
isLessThan(otherSpecificity: SpecificityInstanceOrObject): boolean;
}
type SpecificityInstanceOrObject = Specificity | SpecificityObject;
type CSSTreeAST = Object; // @TODO: Define shape
// CORE
export function calculate(selector: string | CSSTreeAST): Array<Specificity>;
// UTIL: COMPARE
export function equals(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
export function greaterThan(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
export function lessThan(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
export function compare(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): number;
// UTIL: FILTER
export function min(specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
export function max(specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
// UTIL: SORT
export function sortAsc(specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject[];
export function sortDesc(specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject[];