@luolapeikko/ts-common
    Preparing search index...

    Class IterCore

    The core iteration functions.

    v1.0.0

    Index

    Methods

    • Asserts that the given value is an async iterable.

      Type Parameters

      • T

        The type of elements contained in the async iterable.

      Parameters

      • value: unknown

        The value to check.

      Returns asserts value is AsyncIterable<T, any, any>

      The value as an async iterable.

      Will be removed in v1.2.0, use AsyncIterCore.assert instead

      If the value is not an async iterable.

      v1.0.0

    • Asserts that the given value is an iterable.

      Type Parameters

      • T

        The type of elements contained in the iterable.

      Parameters

      • value: unknown

        The value to check.

      Returns asserts value is Iterable<T, any, any>

      The value as an iterable.

      If the value is not an iterable.

      v1.0.0

    • Creates a CoreResult object which contains the result of the validation check.

      Type Parameters

      • V

      Parameters

      • value: V

        The value to check.

      Returns CoreResult<InferAsyncIterable<V>, TypeError>

      Core Result object.

      Will be removed in v1.2.0, use AsyncIterCore.result instead

      v1.1.3

    • Builds value error.

      Parameters

      • value: unknown

        The invalid value.

      • typeName: "AsyncIterable" | "Iterable"

        The expected type name.

      • OptionalisNot: boolean = false

        Whether the error should be for !${typeName}.

      Returns TypeError

      The created error.

      v1.1.3

    • Type guard that checks if a value is an async iterable object.

      Type Parameters

      • T

        The type of elements contained in the async iterable.

      Parameters

      • value: unknown

        The value to check for async iterability.

      Returns value is AsyncIterable<T, any, any>

      true if the value implements the AsyncIterable interface; otherwise, false.

      Will be removed in v1.2.0, use AsyncIterCore.is instead

      v1.0.0

    • Type guard that checks if a value is an iterable object.

      Type Parameters

      • T

        The type of elements contained in the iterable.

      Parameters

      • value: unknown

        The value to check for iterability.

      Returns value is Iterable<T, any, any>

      true if the value implements the Iterable interface; otherwise, false.

      v1.0.0

    • Type guard that checks if a value is not an async iterable object.

      Type Parameters

      • T

        The type of elements contained in the async iterable.

      Parameters

      • value: unknown

        The value to check for non-async iterability.

      Returns value is unknown

      true if the value does not implement the AsyncIterable interface; otherwise, false.

      Will be removed in v1.2.0, use AsyncIterCore.isNot instead

      v1.0.0

    • Type guard that checks if a value is not an iterable object.

      Type Parameters

      • T

        The type of elements contained in the iterable.

      Parameters

      • value: unknown

        The value to check for non-iterability.

      Returns value is unknown

      true if the value does not implement the Iterable interface; otherwise, false.

      v1.0.0

    • Creates a CoreResult object which contains the result of the validation check.

      Type Parameters

      • V

      Parameters

      • value: V

        The value to check.

      Returns CoreResult<InferIterable<V>, TypeError>

      Core Result object.

      v1.1.3

    • Checks if the iterable does not contain the specified value.

      Type Parameters

      • T

        The type of elements contained in the iterable.

      Parameters

      • iterables: Iterable<T>

        The iterable to check.

      • value: T

        The value to check for.

      Returns boolean

      true if the iterable does not contain the value; otherwise, false.

      const values = ['a', 'b', 'c'] as const;
      IterCore.notOneOf(values, 'a'); // false
      IterCore.notOneOf(values, 'd'); // true

      v1.1.3

    • Checks if the iterable contains the specified value.

      Type Parameters

      • T

        The type of elements contained in the iterable.

      Parameters

      • iterables: Iterable<T>

        The iterable to check.

      • value: T

        The value to check for.

      Returns boolean

      true if the iterable contains the value; otherwise, false.

      const values = ['a', 'b', 'c'] as const;
      IterCore.oneOf(values, 'a'); // true
      IterCore.oneOf(values, 'd'); // false

      v1.1.3