Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OrderedHierarchyQuery<TNode, T>

Represents an ordered sequence of hierarchically organized values.

Type parameters

  • TNode
  • T: TNode

Hierarchy

Implements

Index

Constructors

constructor

Methods (Query)

Static choose

  • Creates a Query that iterates the elements from sources picked from a list based on the result of a lazily evaluated choice.

    category

    Query

    Type parameters

    • K
    • V

    Parameters

    • chooser: function

      A callback used to choose a source.

        • (): K
        • Returns K

    • choices: Queryable<Choice<K, V>>

      A list of sources

    • Optional otherwise: Queryable<V>

      A default source to use when another choice could not be made.

    Returns Query<V>

Static consume

Static continuous

  • continuous<T>(value: T): Query<T>
  • Creates a Query that repeats the provided value forever.

    category

    Query

    Type parameters

    • T

    Parameters

    • value: T

      The value for each element of the Query.

    Returns Query<T>

Static empty

Static from

Static generate

  • generate<T>(count: number, generator: function): Query<T>
  • Creates a Query whose values are provided by a callback executed a provided number of times.

    category

    Query

    Type parameters

    • T

    Parameters

    • count: number

      The number of times to execute the callback.

    • generator: function

      The callback to execute.

        • (offset: number): T
        • Parameters

          • offset: number

          Returns T

    Returns Query<T>

Static hierarchy

Static if

  • Creates a Query that iterates the elements from one of two sources based on the result of a lazily evaluated condition.

    category

    Query

    Type parameters

    • T

    Parameters

    • condition: function

      A callback used to choose a source.

        • (): boolean
        • Returns boolean

    • thenQueryable: Queryable<T>

      The source to use when the callback evaluates to true.

    • Optional elseQueryable: Queryable<T>

      The source to use when the callback evaluates to false.

    Returns Query<T>

Static objectEntries

  • Creates a Query for the own property key-value pairs of an object.

    category

    Query

    Type parameters

    • T: object

    Parameters

    • source: T

      An object.

    Returns Query<KeyValuePair<T, Extract<keyof T, string>>>

Static objectKeys

  • objectKeys<T>(source: T): Query<Extract<keyof T, string>>
  • Creates a Query for the own property keys of an object.

    category

    Query

    Type parameters

    • T: object

    Parameters

    • source: T

      An object.

    Returns Query<Extract<keyof T, string>>

Static objectValues

  • objectValues<T>(source: T): Query<T[Extract<keyof T, string>]>
  • Creates a Query for the own property values of an object.

    category

    Query

    Type parameters

    • T: object

    Parameters

    • source: T

      An object.

    Returns Query<T[Extract<keyof T, string>]>

Static of

  • of<T>(...elements: T[]): Query<T>
  • Creates a Query for the provided elements.

    category

    Query

    Type parameters

    • T

    Parameters

    • Rest ...elements: T[]

      The elements of the Query.

    Returns Query<T>

Static once

  • once<T>(value: T): Query<T>
  • Creates a Query over a single element.

    category

    Query

    Type parameters

    • T

    Parameters

    • value: T

      The only element for the Query.

    Returns Query<T>

Static range

  • range(start: number, end: number, increment?: undefined | number): Query<number>
  • Creates a Query over a range of numbers.

    category

    Query

    Parameters

    • start: number

      The starting number of the range.

    • end: number

      The ending number of the range.

    • Optional increment: undefined | number

      The amount by which to change between each itereated value.

    Returns Query<number>

Static repeat

  • repeat<T>(value: T, count: number): Query<T>
  • Creates a Query for a value repeated a provided number of times.

    category

    Query

    Type parameters

    • T

    Parameters

    • value: T

      The value for each element of the Query.

    • count: number

      The number of times to repeat the value.

    Returns Query<T>

Methods (Scalar)

average

  • average(): T extends number ? number : never
  • average(elementSelector: function): number
  • Computes the average for a series of numbers.

    category

    Scalar

    Returns T extends number ? number : never

  • Computes the average for a series of numbers.

    category

    Scalar

    Parameters

    • elementSelector: function
        • (element: T): number
        • Parameters

          • element: T

          Returns number

    Returns number

break

  • break(predicate: function): [Query<T>, Query<T>]
  • Creates a tuple whose first element is a subquery containing the first span of elements that do not match the supplied predicate, and whose second element is a subquery containing the remaining elements.

    The first subquery is eagerly evaluated, while the second subquery is lazily evaluated.

    category

    Scalar

    Parameters

    • predicate: function

      The predicate used to match elements.

        • (element: T, offset: number): boolean
        • Parameters

          • element: T
          • offset: number

          Returns boolean

    Returns [Query<T>, Query<T>]

copyTo

  • copyTo<U>(dest: U, start?: undefined | number, count?: undefined | number): U
  • Writes each element to a destination array.

    category

    Scalar

    Type parameters

    Parameters

    • dest: U

      The destination array.

    • Optional start: undefined | number

      The offset into the array at which to start writing.

    • Optional count: undefined | number

      The number of elements to write to the array.

    Returns U

corresponds

  • corresponds(right: Queryable<T>, equaler?: EqualityComparison<T> | Equaler<T>): boolean
  • corresponds<U>(right: Queryable<U>, equaler: function): boolean
  • Computes a scalar value indicating whether every element in this Query corresponds to a matching element in another Queryable at the same position.

    category

    Scalar

    Parameters

    • right: Queryable<T>

      A Queryable object.

    • Optional equaler: EqualityComparison<T> | Equaler<T>

      An optional callback used to compare the equality of two elements.

    Returns boolean

  • Computes a scalar value indicating whether every element in this Query corresponds to a matching element in another Queryable at the same position.

    category

    Scalar

    Type parameters

    • U

    Parameters

    • right: Queryable<U>

      A Queryable object.

    • equaler: function

      An optional callback used to compare the equality of two elements.

        • (left: T, right: U): boolean
        • Parameters

          • left: T
          • right: U

          Returns boolean

    Returns boolean

correspondsBy

  • correspondsBy<K>(right: Queryable<T>, keySelector: function): boolean
  • correspondsBy<U, K>(right: Queryable<U>, leftKeySelector: function, rightKeySelector: function, keyEqualer?: EqualityComparison<K> | Equaler<K>): boolean
  • Computes a scalar value indicating whether every element in this Query corresponds to a matching element in another Queryable at the same position.

    category

    Scalar

    Type parameters

    • K

    Parameters

    • right: Queryable<T>

      A Queryable object.

    • keySelector: function

      A callback used to select the key for each element.

        • (element: T): K
        • Parameters

          • element: T

          Returns K

    Returns boolean

  • Computes a scalar value indicating whether the key for every element in this Query corresponds to a matching key in right at the same position.

    category

    Scalar

    Type parameters

    • U
    • K

    Parameters

    • right: Queryable<U>

      A Queryable object.

    • leftKeySelector: function

      A callback used to select the key for each element in this Query.

        • (element: T): K
        • Parameters

          • element: T

          Returns K

    • rightKeySelector: function

      A callback used to select the key for each element in right.

        • (element: U): K
        • Parameters

          • element: U

          Returns K

    • Optional keyEqualer: EqualityComparison<K> | Equaler<K>

      An optional callback used to compare the equality of two keys.

    Returns boolean

count

  • count(predicate?: undefined | function): number
  • Counts the number of elements in the Query, optionally filtering elements using the supplied callback.

    category

    Scalar

    Parameters

    • Optional predicate: undefined | function

      An optional callback used to match each element.

    Returns number

drain

  • drain(): void
  • Iterates over all of the elements in the Query, ignoring the results.

    category

    Scalar

    Returns void

elementAt

  • elementAt(offset: number): T | undefined
  • Finds the value in the Query at the provided offset. A negative offset starts from the last element.

    category

    Scalar

    Parameters

    • offset: number

      An offset.

    Returns T | undefined

endsWith

  • endsWith(right: Queryable<T>, equaler?: EqualityComparison<T> | Equaler<T>): boolean
  • endsWith<U>(right: Queryable<U>, equaler: function): boolean
  • Computes a scalar value indicating whether the elements of this Query end with the same sequence of elements in another Queryable.

    category

    Scalar

    Parameters

    • right: Queryable<T>

      A Queryable object.

    • Optional equaler: EqualityComparison<T> | Equaler<T>

      A callback used to compare the equality of two elements.

    Returns boolean

  • Computes a scalar value indicating whether the elements of this Query end with the same sequence of elements in another Queryable.

    category

    Scalar

    Type parameters

    • U

    Parameters

    • right: Queryable<U>

      A Queryable object.

    • equaler: function

      A callback used to compare the equality of two elements.

        • (left: T, right: U): boolean
        • Parameters

          • left: T
          • right: U

          Returns boolean

    Returns boolean

eval

every

  • every<U>(predicate: function): boolean
  • every(predicate: function): boolean
  • Computes a scalar value indicating whether all elements of the Query match the supplied callback.

    category

    Scalar

    Type parameters

    • U: T

    Parameters

    • predicate: function

      A callback used to match each element.

        • (element: T): boolean
        • Parameters

          • element: T

          Returns boolean

    Returns boolean

  • Computes a scalar value indicating whether all elements of the Query match the supplied callback.

    category

    Scalar

    Parameters

    • predicate: function

      A callback used to match each element.

        • (element: T): boolean
        • Parameters

          • element: T

          Returns boolean

    Returns boolean

first

  • first<U>(predicate: function): U | undefined
  • first(predicate?: undefined | function): T | undefined
  • Gets the first element in the Query, optionally filtering elements using the supplied callback.

    category

    Scalar

    Type parameters

    • U: T

    Parameters

    • predicate: function

      An optional callback used to match each element.

        • (element: T): boolean
        • Parameters

          • element: T

          Returns boolean

    Returns U | undefined

  • Gets the first element in the Query, optionally filtering elements using the supplied callback.

    category

    Scalar

    Parameters

    • Optional predicate: undefined | function

      An optional callback used to match each element.

    Returns T | undefined

forEach

  • forEach(callback: function): void
  • Invokes a callback for each element of the Query.

    category

    Scalar

    Parameters

    • callback: function

      The callback to invoke.

        • (element: T, offset: number): void
        • Parameters

          • element: T
          • offset: number

          Returns void

    Returns void

includes

  • includes(value: T, equaler?: EqualityComparison<T> | Equaler<T>): boolean
  • includes<U>(value: U, equaler: function): boolean
  • Computes a scalar value indicating whether the provided value is included in the Query.

    category

    Scalar

    Parameters

    • value: T

      A value.

    • Optional equaler: EqualityComparison<T> | Equaler<T>

      An optional callback used to compare the equality of two elements.

    Returns boolean

  • Computes a scalar value indicating whether the provided value is included in the Query.

    category

    Scalar

    Type parameters

    • U

    Parameters

    • value: U

      A value.

    • equaler: function

      An optional callback used to compare the equality of two elements.

        • (left: T, right: U): boolean
        • Parameters

          • left: T
          • right: U

          Returns boolean

    Returns boolean

includesSequence

  • includesSequence(right: Queryable<T>, equaler?: EqualityComparison<T> | Equaler<T>): boolean
  • includesSequence<U>(right: Queryable<U>, equaler: function): boolean
  • Computes a scalar value indicating whether the elements of this Query include an exact sequence of elements from another Queryable.

    category

    Scalar

    Parameters

    • right: Queryable<T>

      A Queryable object.

    • Optional equaler: EqualityComparison<T> | Equaler<T>

      A callback used to compare the equality of two elements.

    Returns boolean

  • Computes a scalar value indicating whether the elements of this Query include an exact sequence of elements from another Queryable.

    category

    Scalar

    Type parameters

    • U

    Parameters

    • right: Queryable<U>

      A Queryable object.

    • equaler: function

      A callback used to compare the equality of two elements.

        • (left: T, right: U): boolean
        • Parameters

          • left: T
          • right: U

          Returns boolean

    Returns boolean

last

  • last<U>(predicate: function): U | undefined
  • last(predicate?: undefined | function): T | undefined
  • Gets the last element in the Query, optionally filtering elements using the supplied callback.

    category

    Scalar

    Type parameters

    • U: T

    Parameters

    • predicate: function

      An optional callback used to match each element.

        • (element: T): boolean
        • Parameters

          • element: T

          Returns boolean

    Returns U | undefined

  • Gets the last element in the Query, optionally filtering elements using the supplied callback.

    category

    Scalar

    Parameters

    • Optional predicate: undefined | function

      An optional callback used to match each element.

    Returns T | undefined

max

  • max(comparer?: Comparison<T> | Comparer<T>): T | undefined
  • Gets the maximum element in the Query, optionally comparing elements using the supplied callback.

    category

    Scalar

    Parameters

    • Optional comparer: Comparison<T> | Comparer<T>

      An optional callback used to compare two elements.

    Returns T | undefined

maxBy

  • maxBy<K>(keySelector: function, keyComparer?: Comparison<K> | Comparer<K>): T | undefined
  • Gets the maximum element by its key in the Query, optionally comparing the keys of each element using the supplied callback.

    category

    Scalar

    Type parameters

    • K

    Parameters

    • keySelector: function

      A callback used to choose the key to compare.

        • (element: T): K
        • Parameters

          • element: T

          Returns K

    • Optional keyComparer: Comparison<K> | Comparer<K>

      An optional callback used to compare the keys.

    Returns T | undefined

min

  • min(comparer?: Comparison<T> | Comparer<T>): T | undefined
  • Gets the minimum element in the Query, optionally comparing elements using the supplied callback.

    category

    Scalar

    Parameters

    • Optional comparer: Comparison<T> | Comparer<T>

      An optional callback used to compare two elements.

    Returns T | undefined

minBy

  • minBy<K>(keySelector: function, keyComparer?: Comparison<K> | Comparer<K>): T | undefined
  • Gets the minimum element by its key in the Query, optionally comparing the keys of each element using the supplied callback.

    category

    Scalar

    Type parameters

    • K

    Parameters

    • keySelector: function

      A callback used to choose the key to compare.

        • (element: T): K
        • Parameters

          • element: T

          Returns K

    • Optional keyComparer: Comparison<K> | Comparer<K>

      An optional callback used to compare the keys.

    Returns T | undefined

nth

  • nth(offset: number): T | undefined
  • Finds the value in the Query at the provided offset. A negative offset starts from the last element.

    This is an alias for elementAt.

    category

    Scalar

    Parameters

    • offset: number

      An offset.

    Returns T | undefined

reduce

  • reduce(accumulator: function): T
  • reduce<U>(accumulator: function, seed: U, resultSelector?: undefined | function): U
  • reduce<U, R>(accumulator: function, seed: U, resultSelector: function): R
  • Computes a scalar value by applying an accumulator callback over each element.

    category

    Scalar

    Parameters

    • accumulator: function

      the callback used to compute the result.

        • (current: T, element: T, offset: number): T
        • Parameters

          • current: T

            The current accumulated value.

          • element: T

            The value to accumulate.

          • offset: number

            The offset from the start of the underlying Queryable.

          Returns T

    Returns T

  • Computes a scalar value by applying an accumulator callback over each element.

    category

    Scalar

    Type parameters

    • U

    Parameters

    • accumulator: function

      the callback used to compute the result.

        • (current: U, element: T, offset: number): U
        • Parameters

          • current: U

            The current accumulated value.

          • element: T

            The value to accumulate.

          • offset: number

            The offset from the start of the underlying Queryable.

          Returns U

    • seed: U

      An optional seed value.

    • Optional resultSelector: undefined | function

      An optional callback used to compute the final result.

    Returns U

  • Computes a scalar value by applying an accumulator callback over each element.

    category

    Scalar

    Type parameters

    • U
    • R

    Parameters

    • accumulator: function

      the callback used to compute the result.

        • (current: U, element: T, offset: number): U
        • Parameters

          • current: U

            The current accumulated value.

          • element: T

            The value to accumulate.

          • offset: number

            The offset from the start of the underlying Queryable.

          Returns U

    • seed: U

      An optional seed value.

    • resultSelector: function

      An optional callback used to compute the final result.

        • (result: U, count: number): R
        • Parameters

          • result: U
          • count: number

          Returns R

    Returns R

reduceRight

  • reduceRight(accumulator: function): T
  • reduceRight<U>(accumulator: function, seed: U, resultSelector?: undefined | function): U
  • reduceRight<U, R>(accumulator: function, seed: U, resultSelector: function): R
  • Computes a scalar value by applying an accumulator callback over each element in reverse.

    category

    Scalar

    Parameters

    • accumulator: function

      the callback used to compute the result.

        • (current: T, element: T, offset: number): T
        • Parameters

          • current: T
          • element: T
          • offset: number

          Returns T

    Returns T

  • Computes a scalar value by applying an accumulator callback over each element in reverse.

    category

    Scalar

    Type parameters

    • U

    Parameters

    • accumulator: function

      the callback used to compute the result.

        • (current: U, element: T, offset: number): U
        • Parameters

          • current: U
          • element: T
          • offset: number

          Returns U

    • seed: U

      An optional seed value.

    • Optional resultSelector: undefined | function

      An optional callback used to compute the final result.

    Returns U

  • Computes a scalar value by applying an accumulator callback over each element in reverse.

    category

    Scalar

    Type parameters

    • U
    • R

    Parameters

    • accumulator: function

      the callback used to compute the result.

        • (current: U, element: T, offset: number): U
        • Parameters

          • current: U
          • element: T
          • offset: number

          Returns U

    • seed: U

      An optional seed value.

    • resultSelector: function

      An optional callback used to compute the final result.

        • (result: U, count: number): R
        • Parameters

          • result: U
          • count: number

          Returns R

    Returns R

single

  • single<U>(predicate: function): U | undefined
  • single(predicate?: undefined | function): T | undefined
  • Gets the only element in the Query, or returns undefined.

    category

    Scalar

    Type parameters

    • U: T

    Parameters

    • predicate: function

      An optional callback used to match each element.

        • (element: T): boolean
        • Parameters

          • element: T

          Returns boolean

    Returns U | undefined

  • Gets the only element in the Query, or returns undefined.

    category

    Scalar

    Parameters

    • Optional predicate: undefined | function

      An optional callback used to match each element.

    Returns T | undefined

some

  • some(predicate?: undefined | function): boolean
  • Computes a scalar value indicating whether the Query contains any elements, optionally filtering the elements using the supplied callback.

    category

    Scalar

    Parameters

    • Optional predicate: undefined | function

      An optional callback used to match each element.

    Returns boolean

span

  • span<U>(predicate: function): [Query<U>, Query<T>]
  • span(predicate: function): [Query<T>, Query<T>]
  • Creates a tuple whose first element is a subquery containing the first span of elements that match the supplied predicate, and whose second element is a subquery containing the remaining elements.

    The first subquery is eagerly evaluated, while the second subquery is lazily evaluated.

    category

    Scalar

    Type parameters

    • U: T

    Parameters

    • predicate: function

      The predicate used to match elements.

        • (element: T, offset: number): boolean
        • Parameters

          • element: T
          • offset: number

          Returns boolean

    Returns [Query<U>, Query<T>]

  • Creates a tuple whose first element is a subquery containing the first span of elements that match the supplied predicate, and whose second element is a subquery containing the remaining elements.

    The first subquery is eagerly evaluated, while the second subquery is lazily evaluated.

    category

    Scalar

    Parameters

    • predicate: function

      The predicate used to match elements.

        • (element: T, offset: number): boolean
        • Parameters

          • element: T
          • offset: number

          Returns boolean

    Returns [Query<T>, Query<T>]

startsWith

  • startsWith(right: Queryable<T>, equaler?: EqualityComparison<T> | Equaler<T>): boolean
  • startsWith<U>(right: Queryable<U>, equaler: function): boolean
  • Computes a scalar value indicating whether the elements of this Query start with the same sequence of elements in another Queryable.

    category

    Scalar

    Parameters

    • right: Queryable<T>

      A Queryable object.

    • Optional equaler: EqualityComparison<T> | Equaler<T>

      A callback used to compare the equality of two elements.

    Returns boolean

  • Computes a scalar value indicating whether the elements of this Query start with the same sequence of elements in another Queryable.

    category

    Scalar

    Type parameters

    • U

    Parameters

    • right: Queryable<U>

      A Queryable object.

    • equaler: function

      A callback used to compare the equality of two elements.

        • (left: T, right: U): boolean
        • Parameters

          • left: T
          • right: U

          Returns boolean

    Returns boolean

sum

  • sum(): T extends number ? number : never
  • sum(elementSelector: function): number
  • Computes the sum for a series of numbers.

    category

    Scalar

    Returns T extends number ? number : never

  • Computes the sum for a series of numbers.

    category

    Scalar

    Parameters

    • elementSelector: function
        • (element: T): number
        • Parameters

          • element: T

          Returns number

    Returns number

toArray

  • toArray(): T[]
  • toArray<V>(elementSelector: function): V[]
  • Creates an Array for the elements of the Query.

    category

    Scalar

    Returns T[]

  • Creates an Array for the elements of the Query.

    category

    Scalar

    Type parameters

    • V

    Parameters

    • elementSelector: function

      A callback that selects a value for each element.

        • (element: T): V
        • Parameters

          • element: T

          Returns V

    Returns V[]

toLookup

  • toLookup<K>(keySelector: function, keyEqualer?: Equaler<K>): Lookup<K, T>
  • toLookup<K, V>(keySelector: function, elementSelector: function, keyEqualer?: Equaler<K>): Lookup<K, V>
  • Creates a Lookup for the elements of the Query.

    category

    Scalar

    Type parameters

    • K

    Parameters

    • keySelector: function

      A callback used to select a key for each element.

        • (element: T): K
        • Parameters

          • element: T

          Returns K

    • Optional keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns Lookup<K, T>

  • Creates a Lookup for the elements of the Query.

    category

    Scalar

    Type parameters

    • K
    • V

    Parameters

    • keySelector: function

      A callback used to select a key for each element.

        • (element: T): K
        • Parameters

          • element: T

          Returns K

    • elementSelector: function

      A callback that selects a value for each element.

        • (element: T): V
        • Parameters

          • element: T

          Returns V

    • Optional keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns Lookup<K, V>

toMap

  • toMap<K>(keySelector: function): Map<K, T>
  • toMap<K>(keySelector: function, keyEqualer: Equaler<K>): HashMap<K, T>
  • toMap<K, V>(keySelector: function, elementSelector: function): Map<K, V>
  • toMap<K, V>(keySelector: function, elementSelector: function, keyEqualer: Equaler<K>): HashMap<K, V>
  • Creates a Map for the elements of the Query.

    category

    Scalar

    Type parameters

    • K

    Parameters

    • keySelector: function

      A callback used to select a key for each element.

        • (element: T): K
        • Parameters

          • element: T

          Returns K

    Returns Map<K, T>

  • Creates a Map for the elements of the Query.

    category

    Scalar

    Type parameters

    • K

    Parameters

    • keySelector: function

      A callback used to select a key for each element.

        • (element: T): K
        • Parameters

          • element: T

          Returns K

    • keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns HashMap<K, T>

  • Creates a Map for the elements of the Query.

    category

    Scalar

    Type parameters

    • K
    • V

    Parameters

    • keySelector: function

      A callback used to select a key for each element.

        • (element: T): K
        • Parameters

          • element: T

          Returns K

    • elementSelector: function

      A callback that selects a value for each element.

        • (element: T): V
        • Parameters

          • element: T

          Returns V

    Returns Map<K, V>

  • Creates a Map for the elements of the Query.

    category

    Scalar

    Type parameters

    • K
    • V

    Parameters

    • keySelector: function

      A callback used to select a key for each element.

        • (element: T): K
        • Parameters

          • element: T

          Returns K

    • elementSelector: function

      A callback that selects a value for each element.

        • (element: T): V
        • Parameters

          • element: T

          Returns V

    • keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns HashMap<K, V>

toObject

  • toObject(prototype: object | null | undefined, keySelector: function): object
  • toObject<V>(prototype: object | null | undefined, keySelector: function, elementSelector: function, descriptorSelector?: undefined | function): object
  • Creates an Object for the elements of the Query. Properties are added via Object.defineProperty.

    // As a regular object
    const obj = from([["x", 1], ["y", 2]]).toObject(undefined, a => a[0]);
    obj.x; // ["x", 1]
    obj.y; // ["y", 2]
    typeof obj.toString; // function
    
    // with a custom prototype
    const baseObject = { toString() { return `${this.x}:${this.y}` } };
    const obj = from([["x", 1], ["y", 2]]).toObject(baseObject, a => a[0]);
    obj.x; // ["x", 1]
    obj.y; // ["y", 2]
    typeof obj.toString; // function
    obj.toString(); // "x",1:"y",2
    
    // with a null prototype
    const obj = from([["x", 1], ["y", 2]]).toObject(null, a => a[0]);
    obj.x; // ["x", 1]
    obj.y; // ["y", 2]
    typeof obj.toString; // undefined
    category

    Scalar

    Parameters

    • prototype: object | null | undefined

      The prototype for the object. If prototype is null, an object with a null prototype is created. If prototype is undefined, the default Object.prototype is used.

    • keySelector: function

      A callback used to select a key for each element.

        • (element: T): PropertyKey
        • Parameters

          • element: T

          Returns PropertyKey

    Returns object

  • Creates an Object for the elements the Query. Properties are added via Object.defineProperty.

    // As a regular object
    const obj = from([["x", 1], ["y", 2]]).toObject(undefined, a => a[0], a => a[1]);
    obj.x; // 1
    obj.y; // 2
    typeof obj.toString; // function
    
    // with a custom prototype
    const baseObject = { toString() { return `${this.x}:${this.y}` } };
    const obj = from([["x", 1], ["y", 2]]).toObject(baseObject, a => a[0], a => a[1]);
    obj.x; // 1
    obj.y; // 2
    typeof obj.toString; // function
    obj.toString(); // 1:2
    
    // with a null prototype
    const obj = from([["x", 1], ["y", 2]]).toObject(null, a => a[0], a => a[1]);
    obj.x; // 1
    obj.y; // 2
    typeof obj.toString; // undefined
    category

    Scalar

    Type parameters

    • V

    Parameters

    • prototype: object | null | undefined

      The prototype for the object. If prototype is null, an object with a null prototype is created. If prototype is undefined, the default Object.prototype is used.

    • keySelector: function

      A callback used to select a key for each element.

        • (element: T): PropertyKey
        • Parameters

          • element: T

          Returns PropertyKey

    • elementSelector: function

      A callback that selects a value for each element.

        • (element: T): V
        • Parameters

          • element: T

          Returns V

    • Optional descriptorSelector: undefined | function

      A callback that defines the PropertyDescriptor for each property.

    Returns object

toSet

  • toSet(): Set<T>
  • toSet(equaler: Equaler<T>): HashSet<T>
  • toSet<V>(elementSelector: function): Set<V>
  • toSet<V>(elementSelector: function, equaler: Equaler<V>): HashSet<V>
  • Creates a Set for the elements of the Query.

    category

    Scalar

    Returns Set<T>

  • Creates a Set for the elements of the Query.

    category

    Scalar

    Parameters

    • equaler: Equaler<T>

      An [[Equaler]] object used to compare equality.

    Returns HashSet<T>

  • Creates a Set for the elements of the Query.

    category

    Scalar

    Type parameters

    • V

    Parameters

    • elementSelector: function

      A callback that selects a value for each element.

        • (element: T): V
        • Parameters

          • element: T

          Returns V

    Returns Set<V>

  • Creates a Set for the elements of the Query.

    category

    Scalar

    Type parameters

    • V

    Parameters

    • elementSelector: function

      A callback that selects a value for each element.

        • (element: T): V
        • Parameters

          • element: T

          Returns V

    • equaler: Equaler<V>

      An [[Equaler]] object used to compare equality.

    Returns HashSet<V>

unzip

  • unzip(): T extends [any, ...any[]] ? { [I in keyof T]: T[I][]; } : unknown[]
  • unzip<U>(partSelector: function): object
  • Unzips a sequence of tuples into a tuple of sequences.

    category

    Scalar

    Returns T extends [any, ...any[]] ? { [I in keyof T]: T[I][]; } : unknown[]

  • Unzips a sequence of tuples into a tuple of sequences.

    category

    Scalar

    Type parameters

    • U: [any, Array]

    Parameters

    • partSelector: function

      A callback that converts a result into a tuple.

        • (value: T): U
        • Parameters

          • value: T

          Returns U

    Returns object

Methods (Subquery)

append

  • Creates a subquery for the elements of this Query with the provided value appended to the end.

    category

    Subquery

    Parameters

    • value: T

      The value to append.

    Returns UnorderedQueryFlow<this, T>

concat

defaultIfEmpty

distinct

  • Creates a subquery for the distinct elements of this Query.

    category

    Subquery

    Parameters

    • Optional equaler: Equaler<T>

      An [[Equaler]] object used to compare key equality.

    Returns UnorderedQueryFlow<this, T>

distinctBy

  • distinctBy<K>(keySelector: function, keyEqualer?: Equaler<K>): UnorderedQueryFlow<this, T>
  • Creates a subquery for the distinct elements of this Query.

    category

    Subquery

    Type parameters

    • K

    Parameters

    • keySelector: function

      A callback used to select the key to determine uniqueness.

        • (value: T): K
        • Parameters

          • value: T

            An element from which to select a key.

          Returns K

    • Optional keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns UnorderedQueryFlow<this, T>

do

  • Lazily invokes a callback as each element of the Query is iterated.

    category

    Subquery

    Parameters

    • callback: function

      The callback to invoke.

        • (element: T, offset: number): void
        • Parameters

          • element: T

            An element of the source.

          • offset: number

            The offset from the start of the source iterable.

          Returns void

    Returns UnorderedQueryFlow<this, T>

except

exceptBy

  • Creates a subquery for the set difference between this and another Queryable, where set identity is determined by the selected key.

    category

    Subquery

    Type parameters

    • K

    Parameters

    • right: Queryable<T>

      A Queryable object.

    • keySelector: function

      A callback used to select the key for each element.

        • (element: T): K
        • Parameters

          • element: T

            An element from which to select a key.

          Returns K

    • Optional keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns UnorderedQueryFlow<this, T>

exclude

  • Creates a subquery with every instance of the specified value removed.

    category

    Subquery

    Parameters

    • Rest ...values: [T, Array]

      The values to exclude.

    Returns UnorderedQueryFlow<this, T>

expand

  • expand(projection: function): Query<T>
  • Creates a subquery that iterates the results of recursively expanding the elements of the source.

    category

    Subquery

    Parameters

    • projection: function

      A callback used to recusively expand each element.

        • Parameters

          • element: T

            The element to expand.

          Returns Queryable<T>

    Returns Query<T>

filter

  • Creates a subquery whose elements match the supplied predicate.

    category

    Subquery

    Type parameters

    • U: T

    Parameters

    • predicate: function

      A callback used to match each element.

        • (element: T, offset: number): boolean
        • Parameters

          • element: T

            The element to test.

          • offset: number

            The offset from the start of the source iterable.

          Returns boolean

    Returns UnorderedQueryFlow<this, U>

  • Creates a subquery whose elements match the supplied predicate.

    category

    Subquery

    Parameters

    • predicate: function

      A callback used to match each element.

        • (element: T, offset: number): boolean
        • Parameters

          • element: T

            The element to test.

          • offset: number

            The offset from the start of the source iterable.

          Returns boolean

    Returns UnorderedQueryFlow<this, T>

filterBy

  • Creates a subquery where the selected key for each element matches the supplied predicate.

    category

    Subquery

    Type parameters

    • K

    Parameters

    • keySelector: function

      A callback used to select the key for each element.

        • (element: T): K
        • Parameters

          • element: T

            The element from which to select a key.

          Returns K

    • predicate: function

      A callback used to match each key.

        • (key: K, offset: number): boolean
        • Parameters

          • key: K

            The key to test.

          • offset: number

            The offset from the start of the source iterable.

          Returns boolean

    Returns UnorderedQueryFlow<this, T>

filterDefined

  • Creates a subquery whose elements are neither null nor undefined.

    category

    Subquery

    Returns UnorderedQueryFlow<this, NonNullable<T>>

  • Creates a subquery where the selected key for each element is neither null nor undefined.

    category

    Subquery

    Type parameters

    • K

    Parameters

    • keySelector: function

      A callback used to select the key for each element.

        • (element: T): K
        • Parameters

          • element: T

            The element from which to select a key.

          Returns K

    Returns UnorderedQueryFlow<this, T>

flatMap

  • flatMap<U>(projection: function): Query<U>
  • flatMap<U, R>(projection: function, resultSelector: function): Query<R>
  • Creates a subquery that iterates the results of applying a callback to each element.

    category

    Subquery

    Type parameters

    • U

    Parameters

    • projection: function

      A callback used to map each element into a Queryable.

        • Parameters

          • element: T

            The element to map.

          Returns Queryable<U>

    Returns Query<U>

  • Creates a subquery that iterates the results of applying a callback to each element.

    category

    Subquery

    Type parameters

    • U
    • R

    Parameters

    • projection: function

      A callback used to map each element into a Queryable.

        • Parameters

          • element: T

            The outer element to map.

          Returns Queryable<U>

    • resultSelector: function

      An optional callback used to map the outer and projected inner elements.

        • (element: T, innerElement: U): R
        • Parameters

          • element: T

            The outer element to map.

          • innerElement: U

            An inner element produced by the projection of the outer element.

          Returns R

    Returns Query<R>

groupBy

  • groupBy<K>(keySelector: function, keyEqualer?: Equaler<K>): Query<Grouping<K, T>>
  • groupBy<K, V>(keySelector: function, elementSelector: function, keyEqualer?: Equaler<K>): Query<Grouping<K, V>>
  • groupBy<K, V, R>(keySelector: function, elementSelector: function, resultSelector: function, keyEqualer?: Equaler<K>): Query<R>
  • Groups each element of this Query by its key.

    category

    Subquery

    Type parameters

    • K

    Parameters

    • keySelector: function

      A callback used to select the key for an element.

        • (element: T): K
        • Parameters

          • element: T

            An element from which to select a key.

          Returns K

    • Optional keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns Query<Grouping<K, T>>

  • Groups each element by its key.

    category

    Subquery

    Type parameters

    • K
    • V

    Parameters

    • keySelector: function

      A callback used to select the key for an element.

        • (element: T): K
        • Parameters

          • element: T

            An element from which to select a key.

          Returns K

    • elementSelector: function

      A callback used to select a value for an element.

        • (element: T): V
        • Parameters

          • element: T

            An element from which to select a value.

          Returns V

    • Optional keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns Query<Grouping<K, V>>

  • Groups each element by its key.

    category

    Subquery

    Type parameters

    • K
    • V
    • R

    Parameters

    • keySelector: function

      A callback used to select the key for an element.

        • (element: T): K
        • Parameters

          • element: T

            An element from which to select a key.

          Returns K

    • elementSelector: function

      A callback used to select a value for an element.

        • (element: T): V
        • Parameters

          • element: T

            An element from which to select a value.

          Returns V

    • resultSelector: function

      A callback used to select a result from a group.

        • (key: K, elements: Query<V>): R
        • Parameters

          • key: K

            The key for the group.

          • elements: Query<V>

            The elements for the group.

          Returns R

    • Optional keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns Query<R>

intersect

intersectBy

  • intersectBy<UNode, U, K>(right: HierarchyIterable<UNode, U>, keySelector: function, keyEqualer?: Equaler<K>): HierarchyQuery<UNode, U>
  • intersectBy<U, K>(right: Queryable<U>, keySelector: function, keyEqualer?: Equaler<K>): Query<U>
  • intersectBy<K>(right: Queryable<T>, keySelector: function, keyEqualer?: Equaler<K>): Query<T>
  • Creates a subquery for the set intersection of this Query and another Queryable, where set identity is determined by the selected key.

    category

    Subquery

    Type parameters

    • UNode
    • U: UNode & T
    • K

    Parameters

    • right: HierarchyIterable<UNode, U>

      A Queryable object.

    • keySelector: function

      A callback used to select the key for each element.

        • (element: T): K
        • Parameters

          • element: T

            An element from which to select a key.

          Returns K

    • Optional keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns HierarchyQuery<UNode, U>

  • Creates a subquery for the set intersection of this Query and another Queryable, where set identity is determined by the selected key.

    category

    Subquery

    Type parameters

    • U: T
    • K

    Parameters

    • right: Queryable<U>

      A Queryable object.

    • keySelector: function

      A callback used to select the key for each element.

        • (element: T): K
        • Parameters

          • element: T

            An element from which to select a key.

          Returns K

    • Optional keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns Query<U>

  • Creates a subquery for the set intersection of this Query and another Queryable, where set identity is determined by the selected key.

    category

    Subquery

    Type parameters

    • K

    Parameters

    • right: Queryable<T>

      A Queryable object.

    • keySelector: function

      A callback used to select the key for each element.

        • (element: T): K
        • Parameters

          • element: T

            An element from which to select a key.

          Returns K

    • Optional keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns Query<T>

map

  • map<U>(selector: function): Query<U>
  • Creates a subquery by applying a callback to each element.

    category

    Subquery

    Type parameters

    • U

    Parameters

    • selector: function

      A callback used to map each element.

        • (element: T, offset: number): U
        • Parameters

          • element: T

            The element to map.

          • offset: number

            The offset from the start of the source iterable.

          Returns U

    Returns Query<U>

pageBy

  • Creates a subquery that splits this Query into one or more pages. While advancing from page to page is evaluated lazily, the elements of the page are evaluated eagerly.

    category

    Subquery

    Parameters

    • pageSize: number

      The number of elements per page.

    Returns Query<Page<T>>

patch

  • Creates a subquery for the elements of this Query with the provided range patched into the results.

    category

    Subquery

    Parameters

    • start: number

      The offset at which to patch the range.

    • Optional skipCount: undefined | number

      The number of elements to skip from start.

    • Optional range: Queryable<T>

      The range to patch into the result.

    Returns UnorderedQueryFlow<this, T>

prepend

  • Creates a subquery for the elements of this Query with the provided value prepended to the beginning.

    category

    Subquery

    Parameters

    • value: T

      The value to prepend.

    Returns UnorderedQueryFlow<this, T>

relativeComplement

relativeComplementBy

  • Creates a subquery for the set difference between this and another Queryable, where set identity is determined by the selected key.

    category

    Subquery

    Type parameters

    • K

    Parameters

    • right: Queryable<T>

      A Queryable object.

    • keySelector: function

      A callback used to select the key for each element.

        • (element: T): K
        • Parameters

          • element: T

            An element from which to select a key.

          Returns K

    • Optional keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns UnorderedQueryFlow<this, T>

reverse

scan

  • scan(accumulator: function): Query<T>
  • scan<U>(accumulator: function, seed: U): Query<U>
  • Creates a subquery containing the cumulative results of applying the provided callback to each element.

    category

    Subquery

    Parameters

    • accumulator: function

      The callback used to compute each result.

        • (current: T, element: T, offset: number): T
        • Parameters

          • current: T

            The current accumulated value.

          • element: T

            The value to accumulate.

          • offset: number

            The offset from the start of the underlying Queryable.

          Returns T

    Returns Query<T>

  • Creates a subquery containing the cumulative results of applying the provided callback to each element.

    category

    Subquery

    Type parameters

    • U

    Parameters

    • accumulator: function

      The callback used to compute each result.

        • (current: U, element: T, offset: number): U
        • Parameters

          • current: U

            The current accumulated value.

          • element: T

            The value to accumulate.

          • offset: number

            The offset from the start of the underlying Queryable.

          Returns U

    • seed: U

      An optional seed value.

    Returns Query<U>

scanRight

  • scanRight(accumulator: function): Query<T>
  • scanRight<U>(accumulator: function, seed?: U): Query<U>
  • Creates a subquery containing the cumulative results of applying the provided callback to each element in reverse.

    category

    Subquery

    Parameters

    • accumulator: function

      The callback used to compute each result.

        • (current: T, element: T, offset: number): T
        • Parameters

          • current: T

            The current accumulated value.

          • element: T

            The value to accumulate.

          • offset: number

            The offset from the start of the underlying Queryable.

          Returns T

    Returns Query<T>

  • Creates a subquery containing the cumulative results of applying the provided callback to each element in reverse.

    category

    Subquery

    Type parameters

    • U

    Parameters

    • accumulator: function

      The callback used to compute each result.

        • (current: U, element: T, offset: number): U
        • Parameters

          • current: U

            The current accumulated value.

          • element: T

            The value to accumulate.

          • offset: number

            The offset from the start of the underlying Queryable.

          Returns U

    • Optional seed: U

      An optional seed value.

    Returns Query<U>

select

  • select<U>(selector: function): Query<U>
  • Creates a subquery by applying a callback to each element.

    NOTE: This is an alias for map.

    category

    Subquery

    Type parameters

    • U

    Parameters

    • selector: function

      A callback used to map each element.

        • (element: T, offset: number): U
        • Parameters

          • element: T

            The element to map.

          • offset: number

            The offset from the start of the source Queryable.

          Returns U

    Returns Query<U>

selectMany

  • selectMany<U>(projection: function): Query<U>
  • selectMany<U, R>(projection: function, resultSelector: function): Query<R>
  • Creates a subquery that iterates the results of applying a callback to each element.

    NOTE: This is an alias for flatMap.

    category

    Subquery

    Type parameters

    • U

    Parameters

    • projection: function

      A callback used to map each element into an iterable.

        • Parameters

          • element: T

            The element to map.

          Returns Queryable<U>

    Returns Query<U>

  • Creates a subquery that iterates the results of applying a callback to each element.

    NOTE: This is an alias for flatMap.

    category

    Subquery

    Type parameters

    • U
    • R

    Parameters

    • projection: function

      A callback used to map each element into an iterable.

        • Parameters

          • element: T

            The element to map.

          Returns Queryable<U>

    • resultSelector: function

      An optional callback used to map the outer and projected inner elements.

        • (element: T, innerElement: U): R
        • Parameters

          • element: T

            The outer element to map.

          • innerElement: U

            An inner element produced by the projection of the outer element.

          Returns R

    Returns Query<R>

skip

  • Creates a subquery containing all elements except the first elements up to the supplied count.

    category

    Subquery

    Parameters

    • count: number

      The number of elements to skip.

    Returns UnorderedQueryFlow<this, T>

skipRight

  • Creates a subquery containing all elements except the last elements up to the supplied count.

    category

    Subquery

    Parameters

    • count: number

      The number of elements to skip.

    Returns UnorderedQueryFlow<this, T>

skipUntil

  • Creates a subquery containing all elements except the first elements that don't match the supplied predicate.

    category

    Subquery

    Parameters

    • predicate: function

      A callback used to match each element.

        • (element: T): boolean
        • Parameters

          • element: T

            The element to match.

          Returns boolean

    Returns UnorderedQueryFlow<this, T>

skipWhile

  • Creates a subquery containing all elements except the first elements that match the supplied predicate.

    category

    Subquery

    Parameters

    • predicate: function

      A callback used to match each element.

        • (element: T): boolean
        • Parameters

          • element: T

            The element to match.

          Returns boolean

    Returns UnorderedQueryFlow<this, T>

spanMap

  • spanMap<K>(keySelector: function): Query<Grouping<K, T>>
  • spanMap<K, V>(keySelector: function, elementSelector: function): Query<Grouping<K, V>>
  • spanMap<K, V, R>(keySelector: function, elementSelector: function, spanSelector: function): Query<R>
  • Creates a subquery whose elements are the contiguous ranges of elements that share the same key.

    category

    Subquery

    Type parameters

    • K

    Parameters

    • keySelector: function

      A callback used to select the key for an element.

        • (element: T): K
        • Parameters

          • element: T

            An element from which to select a key.

          Returns K

    Returns Query<Grouping<K, T>>

  • Creates a subquery whose values are computed from each element of the contiguous ranges of elements that share the same key.

    category

    Subquery

    Type parameters

    • K
    • V

    Parameters

    • keySelector: function

      A callback used to select the key for an element.

        • (element: T): K
        • Parameters

          • element: T

            An element from which to select a key.

          Returns K

    • elementSelector: function

      A callback used to select a value for an element.

        • (element: T): V
        • Parameters

          • element: T

            An element from which to select a value.

          Returns V

    Returns Query<Grouping<K, V>>

  • Creates a subquery whose values are computed from the contiguous ranges of elements that share the same key.

    category

    Subquery

    Type parameters

    • K
    • V
    • R

    Parameters

    • keySelector: function

      A callback used to select the key for an element.

        • (element: T): K
        • Parameters

          • element: T

            An element from which to select a key.

          Returns K

    • elementSelector: function

      A callback used to select a value for an element.

        • (element: T): V
        • Parameters

          • element: T

            An element from which to select a value.

          Returns V

    • spanSelector: function

      A callback used to select a result from a contiguous range.

        • (key: K, elements: Query<V>): R
        • Parameters

          • key: K

            The key for the span.

          • elements: Query<V>

            The elements for the span.

          Returns R

    Returns Query<R>

symmetricDifference

symmetricDifferenceBy

  • Creates a subquery for the symmetric difference between this and another Queryable, where set identity is determined by the selected key.

    category

    Subquery

    Type parameters

    • K

    Parameters

    • right: Queryable<T>

      A Queryable object.

    • keySelector: function

      A callback used to select the key for each element.

        • (element: T): K
        • Parameters

          • element: T

            An element from which to select a key.

          Returns K

    • Optional keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns UnorderedQueryFlow<this, T>

take

  • Creates a subquery containing the first elements up to the supplied count.

    category

    Subquery

    Parameters

    • count: number

      The number of elements to take.

    Returns UnorderedQueryFlow<this, T>

takeRight

  • Creates a subquery containing the last elements up to the supplied count.

    category

    Subquery

    Parameters

    • count: number

      The number of elements to take.

    Returns UnorderedQueryFlow<this, T>

takeUntil

  • Creates a subquery containing the first elements that do not match the supplied predicate.

    category

    Subquery

    Parameters

    • predicate: function

      A callback used to match each element.

        • (element: T): boolean
        • Parameters

          • element: T

            The element to match.

          Returns boolean

    Returns UnorderedQueryFlow<this, T>

takeWhile

  • Creates a subquery containing the first elements that match the supplied predicate.

    category

    Subquery

    Type parameters

    • U: T

    Parameters

    • predicate: function

      A callback used to match each element.

        • (element: T): boolean
        • Parameters

          • element: T

            The element to match.

          Returns boolean

    Returns UnorderedQueryFlow<this, U>

  • Creates a subquery containing the first elements that match the supplied predicate.

    Parameters

    • predicate: function

      A callback used to match each element.

        • (element: T): boolean
        • Parameters

          • element: T

            The element to match.

          Returns boolean

    Returns UnorderedQueryFlow<this, T>

tap

  • Lazily invokes a callback as each element of the Query is iterated.

    NOTE: This is an alias for do.

    category

    Subquery

    Parameters

    • callback: function

      The callback to invoke.

        • (element: T, offset: number): void
        • Parameters

          • element: T

            An element of the source.

          • offset: number

            The offset from the start of the source iterable.

          Returns void

    Returns UnorderedQueryFlow<this, T>

through

  • Pass the entire Query to the provided callback, creating a new Query from the result.

    category

    Subquery

    Type parameters

    Parameters

    • callback: function

      A callback function.

        • (source: this): R
        • Parameters

          • source: this

            The outer Query.

          Returns R

    Returns QueryFlow<R, QueriedType<R>>

union

unionBy

  • Creates a subquery for the set union of this Query and another Queryable, where set identity is determined by the selected key.

    category

    Subquery

    Type parameters

    • K

    Parameters

    • right: Queryable<T>

      A Queryable object.

    • keySelector: function

      A callback used to select the key for each element.

        • (element: T): K
        • Parameters

          • element: T

            An element from which to select a key.

          Returns K

    • Optional keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns UnorderedQueryFlow<this, T>

where

  • Creates a subquery whose elements match the supplied predicate.

    NOTE: This is an alias for filter.

    category

    Subquery

    Type parameters

    • U: T

    Parameters

    • predicate: function

      A callback used to match each element.

        • (element: T, offset: number): boolean
        • Parameters

          • element: T

            The element to test.

          • offset: number

            The offset from the start of the source iterable.

          Returns boolean

    Returns UnorderedQueryFlow<this, U>

  • Creates a subquery whose elements match the supplied predicate.

    NOTE: This is an alias for filter.

    category

    Subquery

    Parameters

    • predicate: function

      A callback used to match each element.

        • (element: T, offset: number): boolean
        • Parameters

          • element: T

            The element to test.

          • offset: number

            The offset from the start of the source iterable.

          Returns boolean

    Returns UnorderedQueryFlow<this, T>

whereBy

  • Creates a subquery where the selected key for each element matches the supplied predicate.

    NOTE: This is an alias for filterBy.

    category

    Subquery

    Type parameters

    • K

    Parameters

    • keySelector: function

      A callback used to select the key for each element.

        • (element: T): K
        • Parameters

          • element: T

            The element from which to select a key.

          Returns K

    • predicate: function

      A callback used to match each key.

        • (key: K, offset: number): boolean
        • Parameters

          • key: K

            The key to test.

          • offset: number

            The offset from the start of the source iterable.

          Returns boolean

    Returns UnorderedQueryFlow<this, T>

whereDefined

  • Creates a subquery whose elements are neither null nor undefined.

    NOTE: This is an alias for filterDefined.

    category

    Subquery

    Returns UnorderedQueryFlow<this, NonNullable<T>>

  • Creates a subquery where the selected key for each element is neither null nor undefined.

    NOTE: This is an alias for filterDefined.

    category

    Subquery

    Type parameters

    • K

    Parameters

    • keySelector: function

      A callback used to select the key for each element.

        • (element: T): K
        • Parameters

          • element: T

            The element from which to select a key.

          Returns K

    Returns UnorderedQueryFlow<this, T>

xor

xorBy

  • Creates a subquery for the symmetric difference between this and another Queryable, where set identity is determined by the selected key.

    NOTE: This is an alias for symmetricDifferenceBy.

    category

    Subquery

    Type parameters

    • K

    Parameters

    • right: Queryable<T>

      A Queryable object.

    • keySelector: function

      A callback used to select the key for each element.

        • (element: T): K
        • Parameters

          • element: T

            An element from which to select a key.

          Returns K

    • Optional keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns UnorderedQueryFlow<this, T>

Methods (Order)

orderBy

  • orderBy<K>(keySelector: function, comparer?: Comparison<K> | Comparer<K>): OrderedQueryFlow<this, T>
  • Creates an ordered subquery whose elements are sorted in ascending order by the provided key.

    category

    Order

    Type parameters

    • K

    Parameters

    • keySelector: function

      A callback used to select the key for an element.

        • (element: T): K
        • Parameters

          • element: T

          Returns K

    • Optional comparer: Comparison<K> | Comparer<K>

      An optional callback used to compare two keys.

    Returns OrderedQueryFlow<this, T>

orderByDescending

  • orderByDescending<K>(keySelector: function, comparer?: Comparison<K> | Comparer<K>): OrderedQueryFlow<this, T>
  • Creates an ordered subquery whose elements are sorted in descending order by the provided key.

    category

    Order

    Type parameters

    • K

    Parameters

    • keySelector: function

      A callback used to select the key for an element.

        • (element: T): K
        • Parameters

          • element: T

          Returns K

    • Optional comparer: Comparison<K> | Comparer<K>

      An optional callback used to compare two keys.

    Returns OrderedQueryFlow<this, T>

thenBy

  • thenBy<K>(keySelector: function, comparison?: Comparison<K> | Comparer<K>): OrderedHierarchyQuery<TNode, T>
  • Creates a subsequent ordered subquery whose elements are sorted in ascending order by the provided key.

    category

    Order

    Type parameters

    • K

    Parameters

    • keySelector: function

      A callback used to select the key for an element.

        • (element: T): K
        • Parameters

          • element: T

          Returns K

    • Optional comparison: Comparison<K> | Comparer<K>

      An optional callback used to compare two keys.

    Returns OrderedHierarchyQuery<TNode, T>

thenByDescending

  • thenByDescending<K>(keySelector: function, comparison?: Comparison<K> | Comparer<K>): OrderedHierarchyQuery<TNode, T>
  • Creates a subsequent ordered subquery whose elements are sorted in descending order by the provided key.

    category

    Order

    Type parameters

    • K

    Parameters

    • keySelector: function

      A callback used to select the key for an element.

        • (element: T): K
        • Parameters

          • element: T

          Returns K

    • Optional comparison: Comparison<K> | Comparer<K>

      An optional callback used to compare two keys.

    Returns OrderedHierarchyQuery<TNode, T>

Methods (Join)

fullJoin

  • fullJoin<I, K, R>(inner: Queryable<I>, outerKeySelector: function, innerKeySelector: function, resultSelector: function, keyEqualer?: Equaler<K>): Query<R>
  • Creates a subquery for the correlated elements of this Query and another Queryable.

    category

    Join

    Type parameters

    • I
    • K
    • R

    Parameters

    • inner: Queryable<I>

      A Queryable object.

    • outerKeySelector: function

      A callback used to select the key for an element in this Query.

        • (element: T): K
        • Parameters

          • element: T

          Returns K

    • innerKeySelector: function

      A callback used to select the key for an element in the other Queryable.

        • (element: I): K
        • Parameters

          • element: I

          Returns K

    • resultSelector: function

      A callback used to select the result for the correlated elements.

        • (outer: T | undefined, inner: I | undefined): R
        • Parameters

          • outer: T | undefined
          • inner: I | undefined

          Returns R

    • Optional keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns Query<R>

groupJoin

  • groupJoin<I, K, R>(inner: Queryable<I>, outerKeySelector: function, innerKeySelector: function, resultSelector: function, keyEqualer?: Equaler<K>): Query<R>
  • Creates a grouped subquery for the correlated elements of this Query and another Queryable object.

    category

    Join

    Type parameters

    • I
    • K
    • R

    Parameters

    • inner: Queryable<I>

      A Queryable object.

    • outerKeySelector: function

      A callback used to select the key for an element in this Query.

        • (element: T): K
        • Parameters

          • element: T

          Returns K

    • innerKeySelector: function

      A callback used to select the key for an element in the other Queryable object.

        • (element: I): K
        • Parameters

          • element: I

          Returns K

    • resultSelector: function

      A callback used to select the result for the correlated elements.

        • (outer: T, inner: Query<I>): R
        • Parameters

          • outer: T
          • inner: Query<I>

          Returns R

    • Optional keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns Query<R>

join

  • join<I, K, R>(inner: Queryable<I>, outerKeySelector: function, innerKeySelector: function, resultSelector: function, keyEqualer?: Equaler<K>): Query<R>
  • Creates a subquery for the correlated elements of this Query and another Queryable.

    category

    Join

    Type parameters

    • I
    • K
    • R

    Parameters

    • inner: Queryable<I>

      A Queryable object.

    • outerKeySelector: function

      A callback used to select the key for an element in this Query.

        • (element: T): K
        • Parameters

          • element: T

          Returns K

    • innerKeySelector: function

      A callback used to select the key for an element in the other Queryable.

        • (element: I): K
        • Parameters

          • element: I

          Returns K

    • resultSelector: function

      A callback used to select the result for the correlated elements.

        • (outer: T, inner: I): R
        • Parameters

          • outer: T
          • inner: I

          Returns R

    • Optional keyEqualer: Equaler<K>

      An [[Equaler]] object used to compare key equality.

    Returns Query<R>

zip

  • Creates a subquery that combines this Query with another Queryable by combining elements in tuples.

    category

    Join

    Type parameters

    • U

    Parameters

    Returns Query<[T, U]>

  • Creates a subquery that combines this Query with another Queryable by combining elements using the supplied callback.

    category

    Join

    Type parameters

    • U
    • R

    Parameters

    • right: Queryable<U>

      A Queryable object.

    • selector: function

      A callback used to combine two elements.

        • (left: T, right: U): R
        • Parameters

          • left: T
          • right: U

          Returns R

    Returns Query<R>

Methods (Hierarchy)

ancestors

  • Creates a subquery for the ancestors of each element in the hierarchy.

    category

    Hierarchy

    Type parameters

    • U: TNode

    Parameters

    • predicate: function

      A callback used to filter the results.

        • (element: TNode): boolean
        • Parameters

          • element: TNode

          Returns boolean

    Returns HierarchyQuery<TNode, U>

  • Creates a subquery for the ancestors of each element in the hierarchy.

    category

    Hierarchy

    Parameters

    • Optional predicate: undefined | function

      A callback used to filter the results.

    Returns HierarchyQuery<TNode>

ancestorsAndSelf

  • ancestorsAndSelf<U>(predicate: function): HierarchyQuery<TNode, U>
  • ancestorsAndSelf(predicate?: undefined | function): HierarchyQuery<TNode>
  • Creates a subquery for the ancestors of each element as well as each element in the hierarchy.

    category

    Hierarchy

    Type parameters

    • U: TNode

    Parameters

    • predicate: function

      A callback used to filter the results.

        • (element: TNode): boolean
        • Parameters

          • element: TNode

          Returns boolean

    Returns HierarchyQuery<TNode, U>

  • Creates a subquery for the ancestors of each element as well as each element in the hierarchy.

    category

    Hierarchy

    Parameters

    • Optional predicate: undefined | function

      A callback used to filter the results.

    Returns HierarchyQuery<TNode>

bottomMost

  • Creates a subquery for the bottom-most elements. Elements that are an ancestor of any other element are removed.

    category

    Hierarchy

    Type parameters

    • U: T

    Parameters

    • predicate: function
        • (element: T): boolean
        • Parameters

          • element: T

          Returns boolean

    Returns HierarchyQuery<TNode, U>

  • Creates a subquery for the bottom-most elements. Elements that are an ancestor of any other element are removed.

    category

    Hierarchy

    Parameters

    • Optional predicate: undefined | function

    Returns HierarchyQuery<TNode, T>

children

  • Creates a subquery for the children of each element in the hierarchy.

    category

    Hierarchy

    Type parameters

    • U: TNode

    Parameters

    • predicate: function

      A callback used to filter the results.

        • (element: TNode): boolean
        • Parameters

          • element: TNode

          Returns boolean

    Returns HierarchyQuery<TNode, U>

  • Creates a subquery for the children of each element in the hierarchy.

    category

    Hierarchy

    Parameters

    • Optional predicate: undefined | function

      A callback used to filter the results.

    Returns HierarchyQuery<TNode>

descendants

  • Creates a subquery for the descendants of each element in the hierarchy.

    category

    Hierarchy

    Type parameters

    • U: TNode

    Parameters

    • predicate: function

      A callback used to filter the results.

        • (element: TNode): boolean
        • Parameters

          • element: TNode

          Returns boolean

    Returns HierarchyQuery<TNode, U>

  • Creates a subquery for the descendants of each element in the hierarchy.

    category

    Hierarchy

    Parameters

    • Optional predicate: undefined | function

      A callback used to filter the results.

    Returns HierarchyQuery<TNode>

descendantsAndSelf

  • descendantsAndSelf<U>(predicate: function): HierarchyQuery<TNode, U>
  • descendantsAndSelf(predicate?: undefined | function): HierarchyQuery<TNode>
  • Creates a subquery for the descendants of each element as well as each element in the hierarchy.

    category

    Hierarchy

    Type parameters

    • U: TNode

    Parameters

    • predicate: function

      A callback used to filter the results.

        • (element: TNode): boolean
        • Parameters

          • element: TNode

          Returns boolean

    Returns HierarchyQuery<TNode, U>

  • Creates a subquery for the descendants of each element as well as each element in the hierarchy.

    category

    Hierarchy

    Parameters

    • Optional predicate: undefined | function

      A callback used to filter the results.

    Returns HierarchyQuery<TNode>

nthChild

  • Creates a subquery for the child of each element at the specified offset. A negative offset starts from the last child.

    category

    Hierarchy

    Parameters

    • offset: number

      The offset for the child.

    Returns HierarchyQuery<TNode>

parents

  • Creates a subquery for the parents of each element in the hierarchy.

    category

    Hierarchy

    Type parameters

    • U: TNode

    Parameters

    • predicate: function

      A callback used to filter the results.

        • (element: TNode): boolean
        • Parameters

          • element: TNode

          Returns boolean

    Returns HierarchyQuery<TNode, U>

  • Creates a subquery for the parents of each element in the hierarchy.

    category

    Hierarchy

    Parameters

    • Optional predicate: undefined | function

      A callback used to filter the results.

    Returns HierarchyQuery<TNode>

root

  • Creates a subquery for the roots of each element in the hierarchy.

    category

    Hierarchy

    Type parameters

    • U: TNode

    Parameters

    • predicate: function

      A callback used to filter the results.

        • (element: TNode): boolean
        • Parameters

          • element: TNode

          Returns boolean

    Returns HierarchyQuery<TNode, U>

  • Creates a subquery for the roots of each element in the hierarchy.

    category

    Hierarchy

    Parameters

    • Optional predicate: undefined | function

      A callback used to filter the results.

    Returns HierarchyQuery<TNode>

self

  • Creates a subquery for this [[query]].

    category

    Hierarchy

    Type parameters

    • U: T

    Parameters

    • predicate: function

      A callback used to filter the results.

        • (element: TNode): boolean
        • Parameters

          • element: TNode

          Returns boolean

    Returns HierarchyQuery<TNode, U>

  • Creates a subquery for this [[query]].

    category

    Hierarchy

    Type parameters

    • U: TNode

    Parameters

    • predicate: function

      A callback used to filter the results.

        • (element: TNode): boolean
        • Parameters

          • element: TNode

          Returns boolean

    Returns HierarchyQuery<TNode, U>

  • Creates a subquery for this [[query]].

    category

    Hierarchy

    Parameters

    • Optional predicate: undefined | function

      A callback used to filter the results.

    Returns HierarchyQuery<TNode>

siblings

  • Creates a subquery for the siblings of each element in the hierarchy.

    category

    Hierarchy

    Type parameters

    • U: TNode

    Parameters

    • predicate: function

      A callback used to filter the results.

        • (element: TNode): boolean
        • Parameters

          • element: TNode

          Returns boolean

    Returns HierarchyQuery<TNode, U>

  • Creates a subquery for the siblings of each element in the hierarchy.

    category

    Hierarchy

    Parameters

    • Optional predicate: undefined | function

      A callback used to filter the results.

    Returns HierarchyQuery<TNode>

siblingsAfterSelf

  • siblingsAfterSelf<U>(predicate: function): HierarchyQuery<TNode, U>
  • siblingsAfterSelf(predicate?: undefined | function): HierarchyQuery<TNode>
  • Creates a subquery for the siblings after each element in the hierarchy.

    category

    Hierarchy

    Type parameters

    • U: TNode

    Parameters

    • predicate: function

      A callback used to filter the results.

        • (element: TNode): boolean
        • Parameters

          • element: TNode

          Returns boolean

    Returns HierarchyQuery<TNode, U>

  • Creates a subquery for the siblings after each element in the hierarchy.

    category

    Hierarchy

    Parameters

    • Optional predicate: undefined | function

      A callback used to filter the results.

    Returns HierarchyQuery<TNode>

siblingsAndSelf

  • siblingsAndSelf<U>(predicate: function): HierarchyQuery<TNode, U>
  • siblingsAndSelf(predicate?: undefined | function): HierarchyQuery<TNode>
  • Creates a subquery for the siblings of each element as well as each element in the hierarchy.

    category

    Hierarchy

    Type parameters

    • U: TNode

    Parameters

    • predicate: function

      A callback used to filter the results.

        • (element: TNode): boolean
        • Parameters

          • element: TNode

          Returns boolean

    Returns HierarchyQuery<TNode, U>

  • Creates a subquery for the siblings of each element as well as each element in the hierarchy.

    category

    Hierarchy

    Parameters

    • Optional predicate: undefined | function

      A callback used to filter the results.

    Returns HierarchyQuery<TNode>

siblingsBeforeSelf

  • siblingsBeforeSelf<U>(predicate: function): HierarchyQuery<TNode, U>
  • siblingsBeforeSelf(predicate?: undefined | function): HierarchyQuery<TNode>
  • Creates a subquery for the siblings before each element in the hierarchy.

    category

    Hierarchy

    Type parameters

    • U: TNode

    Parameters

    • predicate: function

      A callback used to filter the results.

        • (element: TNode): boolean
        • Parameters

          • element: TNode

          Returns boolean

    Returns HierarchyQuery<TNode, U>

  • Creates a subquery for the siblings before each element in the hierarchy.

    category

    Hierarchy

    Parameters

    • Optional predicate: undefined | function

      A callback used to filter the results.

    Returns HierarchyQuery<TNode>

toHierarchy

topMost

  • Creates a subquery for the top-most elements. Elements that are a descendant of any other element are removed.

    category

    Hierarchy

    Type parameters

    • U: T

    Parameters

    • predicate: function
        • (element: T): boolean
        • Parameters

          • element: T

          Returns boolean

    Returns HierarchyQuery<TNode, U>

  • Creates a subquery for the top-most elements. Elements that are a descendant of any other element are removed.

    category

    Hierarchy

    Parameters

    • Optional predicate: undefined | function

    Returns HierarchyQuery<TNode, T>

Methods ()

[Hierarchical.hierarchy]

[OrderedIterable.thenBy]

  • [OrderedIterable.thenBy]<K>(keySelector: function, comparison: Comparison<K> | Comparer<K>, descending: boolean): OrderedHierarchyIterable<TNode, T>
  • Type parameters

    • K

    Parameters

    • keySelector: function
        • (element: T): K
        • Parameters

          • element: T

          Returns K

    • comparison: Comparison<K> | Comparer<K>
    • descending: boolean

    Returns OrderedHierarchyIterable<TNode, T>

[Symbol.iterator]

toJSON

  • toJSON(): T[]

Generated using TypeDoc