Class KoconutPair<FirstType, SecondType>

Koconut Wrapper class for Pair

See

-- Base --
[Pair](Pair.html), [Entry](Entry.html), [KoconutPair](KoconutPair.html)

-- Protocol --
[KoconutEquatable](../interfaces/KoconutEquatable.html)

Type Parameters

  • FirstType

    Check for Pair

  • SecondType

    Check for Pair

Hierarchy

Implements

Constructors

Methods - Other

Methods - Processor

Constructors

Other Methods

Processor Methods

  • Processes all the chained objects and calls the specified function block with the result value as its argument and returns the original result.

    Since

    1.0.10

    Example

    import { KoconutArray } from 'koconut'

    const mainProcess = async () => {
    const koconutNumbers = KoconutArray.of(1,2,3,4,5)

    const moreNumbers = await koconutNumbers
    .also(result => {
    result.push(6)
    result.push(7)
    result.push(8)
    })
    console.log(moreNumbers)
    // ↑ [1, 2, 3, 4, 5, 6, 7, 8]
    }
    mainProcess()

    Parameters

    • block: Processor<Pair<FirstType, SecondType>>

      A callback function that accepts an argument.

    Returns Promise<null | Pair<FirstType, SecondType>>

  • Processes all the chained objects and calls the specified function block with the result value as its argument and returns the final result of the block.

    Since

    1.0.10

    Example

    import { KoconutArray } from 'koconut'

    const mainProcess = async () => {
    const koconutNumbers = KoconutArray.of(1,2,3,4,5)

    const firstNumberPlus2 = await koconutNumbers
    .first()
    .let(result => result + 2)
    console.log(firstNumber)
    // ↑ 3
    }
    mainProcess()

    Type Parameters

    • ReturnType

    Parameters

    • block: Selector<Pair<FirstType, SecondType>, ReturnType>

      A callback function that accepts an argument. The method calls the block and returns its result.

    Returns Promise<ReturnType>

  • Processes all the chained objects ane returns Promise<void>.

    Since

    1.0.10

    Example

    import { KoconutArray } from 'koconut'

    const mainProcess = async () => {
    const koconutNumbers = KoconutArray.of(1,2,3,4,5)

    await koconutNumbers
    .forEach(console.log)
    .process()
    // ↑ 1 2 3 4 5
    }
    mainProcess()

    Returns Promise<void>

  • Processes all the chained objects and return the result.

    Since

    1.0.10

    Example

    import { KoconutArray } from 'koconut'

    const mainProcess = async () => {
    const koconutNumbers = KoconutArray.of(1,2,3,4,5)

    const firstNumber = await koconutNumbers
    .first()
    .yield()
    console.log(firstNumber)
    // ↑ 1
    }
    mainProcess()

    Returns Promise<Pair<FirstType, SecondType>>

Generated using TypeDoc