Trilium Frontend API
    Preparing search index...

    Class RangeSet<T>

    A range set stores a collection of ranges in a way that makes them efficient to map and update. This is an immutable data structure.

    Type Parameters

    Index

    Properties

    Accessors

    Methods

    Properties

    empty: RangeSet<any>

    The empty set of ranges.

    Accessors

    • get size(): number

      The number of ranges in the set.

      Returns number

    Methods

    • Iterate over the ranges that touch the region from to to, calling f for each. There is no guarantee that the ranges will be reported in any specific order. When the callback returns false, iteration stops.

      Parameters

      • from: number
      • to: number
      • f: (from: number, to: number, value: T) => false | void

      Returns void

    • Iterate over the ranges in this set, in order, including all ranges that end at or after from.

      Parameters

      • Optionalfrom: number

      Returns RangeCursor<T>

    • Map this range set through a set of changes, return the new set.

      Parameters

      Returns RangeSet<T>

    • Update the range set, optionally adding new ranges or filtering out existing ones.

      (Note: The type parameter is just there as a kludge to work around TypeScript variance issues that prevented RangeSet<X> from being a subtype of RangeSet<Y> when X is a subtype of Y.)

      Type Parameters

      Parameters

      Returns RangeSet<T>

    • Iterate over two groups of sets, calling methods on comparator to notify it of possible differences.

      Type Parameters

      Parameters

      • oldSets: readonly RangeSet<T>[]
      • newSets: readonly RangeSet<T>[]
      • textDiff: ChangeDesc

        This indicates how the underlying data changed between these ranges, and is needed to synchronize the iteration.

      • comparator: RangeComparator<T>
      • OptionalminPointSize: number

        Can be used to ignore all non-point ranges, and points below the given size. When -1, all ranges are compared.

      Returns void

    • Compare the contents of two groups of range sets, returning true if they are equivalent in the given range.

      Type Parameters

      Parameters

      • oldSets: readonly RangeSet<T>[]
      • newSets: readonly RangeSet<T>[]
      • Optionalfrom: number
      • Optionalto: number

      Returns boolean

    • Iterate over the ranges in a collection of sets, in order, starting from from.

      Type Parameters

      Parameters

      • sets: readonly RangeSet<T>[]
      • Optionalfrom: number

      Returns RangeCursor<T>

    • Create a range set for the given range or array of ranges. By default, this expects the ranges to be sorted (by start position and, if two start at the same position, value.startSide). You can pass true as second argument to cause the method to sort them.

      Type Parameters

      Parameters

      Returns RangeSet<T>

    • Iterate over a group of range sets at the same time, notifying the iterator about the ranges covering every given piece of content. Returns the open count (see SpanIterator.span) at the end of the iteration.

      Type Parameters

      Parameters

      • sets: readonly RangeSet<T>[]
      • from: number
      • to: number
      • iterator: SpanIterator<T>
      • OptionalminPointSize: number

        When given and greater than -1, only points of at least this size are taken into account.

      Returns number