Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

specificity.d.ts 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * Specificity arrays always have 4 numbers (integers) for quick comparison
  3. * comparing from left to right, the next number only has to be checked if
  4. * two numbers of the same index are equal.
  5. */
  6. export type SpecificityArray = [number, number, number, number];
  7. /**
  8. * A result of parsing a selector into an array of parts.
  9. * Calculating a specificity array is a matter of summing
  10. * over all the parts and adding the values to the right
  11. * bucket in a specificity array.
  12. *
  13. * @interface Part
  14. */
  15. export interface Part {
  16. selector: string;
  17. type: 'a' | 'b' | 'c';
  18. index: number;
  19. length: number;
  20. }
  21. /**
  22. * Returned by the calculate function. Represents the results
  23. * of parsing and calculating the specificity of a selector.
  24. *
  25. * @interface Specificity
  26. */
  27. export interface Specificity {
  28. selector: string;
  29. specificity: string;
  30. specificityArray: SpecificityArray;
  31. parts: Array<Part>;
  32. }
  33. /**
  34. * Calculates the specificity for the given selector string.
  35. * If the string contains a comma, each selector will be parsed
  36. * separately.
  37. *
  38. * @returns A list of specificity objects one for each selector in the
  39. * selector string.
  40. */
  41. export function calculate(selector: string): Array<Specificity>;
  42. /**
  43. * Compares two selectors. If a string, the string cannot contain a comma.
  44. *
  45. * @returns A value less than 0 if selector a is less specific than selector b.
  46. * A value more than 0 if selector a is more specific than selector b.
  47. * 0 if the two selectors have the same specificity.
  48. */
  49. export function compare(a: string | SpecificityArray, b: string | SpecificityArray): -1 | 0 | 1;