1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 1x 1x 1x 1x 1x 1x 25x 18x 2x 2x 2x 1x | export enum Combinator { DESCENDANT, CHILD, ADJACENT_SIBLING, GENERAL_SIBLING, } export function parseCombinator(combinator: string): Combinator { switch (combinator){ case undefined: case null: case '': return Combinator.DESCENDANT; case '>': return Combinator.CHILD; case '+': return Combinator.ADJACENT_SIBLING; case '~': return Combinator.GENERAL_SIBLING; default: throw new Error(`Unknown combinator "${combinator}"`); } } |