Options
All
  • Public
  • Public/Protected
  • All
Menu

Class for sorting imports and the import elements.

Hierarchy

  • ImportSorter

Index

Methods

  • chainCompareFunctions<T>(sortRules: ((a: T, b: T) => number)[]): ((a: T, b: T) => number)
  • Function to chain compare functions together.

    Type Parameters

    • T

    Parameters

    • sortRules: ((a: T, b: T) => number)[]

      An array of compare functions for the same type

    Returns ((a: T, b: T) => number)

    A new compare function running through every compare function until it finds a non 0 value

      • (a: T, b: T): number
      • Function to chain compare functions together.

        Parameters

        • a: T
        • b: T

        Returns number

        A new compare function running through every compare function until it finds a non 0 value

  • inverseComparator<T>(comparator: ((a: T, b: T) => number)): ((a: T, b: T) => number)
  • Helper function to get the inverse of a comparator function. Since comparator functions simply return numbers, this just returns the negation of them.

    Type Parameters

    • T

    Parameters

    • comparator: ((a: T, b: T) => number)

      comparator function

        • (a: T, b: T): number
        • Parameters

          • a: T
          • b: T

          Returns number

    Returns ((a: T, b: T) => number)

    inverse of a comparator function

      • (a: T, b: T): number
      • Helper function to get the inverse of a comparator function. Since comparator functions simply return numbers, this just returns the negation of them.

        Parameters

        • a: T
        • b: T

        Returns number

        inverse of a comparator function

  • shouldInverse(rule: string): [string, boolean]
  • Helper function to get the rule name and if it should get inverted.

    A "!" prepending the sort rule indicates inverting it.

    Parameters

    • rule: string

      The name of a sort rule given from the config

    Returns [string, boolean]

Constructors

Properties

sortImportElementOrder: ImportElementCompareFunction[] = []

Array of import element compare functions. The order of elements is important here.

sortImportOrder: ImportCompareFunction[] = []

Array of import compare functions. The order of elements is important here.

Generated using TypeDoc