deep-trails - v3.0.0-beta.3
    Preparing search index...

    Type Alias EntriesIterator<F, T, K, V>

    Entries iterable iterator.

    The deep-trails factory functions create closures to store the iteration state. Therefore, they do not depend on this.

    3.0.0-beta.0

    type EntriesIterator<
        F extends
            <O extends T>(object: O, ...args: any[]) => EntriesIterator<F, T, K, V>,
        T extends object,
        K = unknown,
        V = unknown,
    > = {
        "[iterator]": () => { next: EntriesIterator<F, T, K, V>["next"] };
        destroy: () => boolean;
        factory: F;
        next: () => | { done: false; value: [key: K, value: V, index: number] }
        | { done: true; value: null };
        object: T;
        peek: (
            difference?: number,
        ) =>
            | { done: false; value: [key: K, value: V, index: number] }
            | { done: boolean; value: null | undefined };
        reset: () => boolean;
        size: number | undefined;
    }

    Type Parameters

    • F extends <O extends T>(object: O, ...args: any[]) => EntriesIterator<F, T, K, V>
    • T extends object
    • K = unknown
    • V = unknown
    Index

    Properties

    "[iterator]": () => { next: EntriesIterator<F, T, K, V>["next"] }

    Method that makes this iterator iterable.

    Calling it resets the iteration state.

    Type Declaration

    destroy: () => boolean

    Destroys the iterator, and makes it unusable. This helps to eliminate the closure.

    Type Declaration

      • (): boolean
      • Returns boolean

        True if it was destroyed in this call, false if it had already been destroyed.

    factory: F

    The function that created this iterator.

    next: () => | { done: false; value: [key: K, value: V, index: number] }
    | { done: true; value: null }

    Advances in the iteration, changing its state.

    Type Declaration

      • (): | { done: false; value: [key: K, value: V, index: number] }
        | { done: true; value: null }
      • Returns
            | { done: false; value: [key: K, value: V, index: number] }
            | { done: true; value: null }

        The next state of the iteration.

    object: T

    The object received to iterate it.

    peek: (
        difference?: number,
    ) =>
        | { done: false; value: [key: K, value: V, index: number] }
        | { done: boolean; value: null | undefined }

    Peeks an iteration state.

    The entry will be:

    • null if the zero-based index is out of the valid and known range.
    • undefined if the iterator cannot provide peeking functionality.
    • An array as entry otherwise.

    Type Declaration

      • (
            difference?: number,
        ):
            | { done: false; value: [key: K, value: V, index: number] }
            | { done: boolean; value: null | undefined }
      • Parameters

        • Optionaldifference: number

          Integer indicating the target from the current index. By default is +1.

          • =0: Current.
          • >0: Future.
          • <0: Past.

        Returns
            | { done: false; value: [key: K, value: V, index: number] }
            | { done: boolean; value: null | undefined }

    reset: () => boolean

    Resets the iteration state.

    If reseted, only the iternal data (closure) will change.

    Type Declaration

      • (): boolean
      • Returns boolean

        True if reseted, otherwise false.

    size: number | undefined

    Number of items detected in the object.

    It is undefined if there was no known way to obtain it.