Class KoconutBoolean

Classes which inherit from this protocol have a defined total ordering between their instances

Hierarchy

Implements

Constructors

Methods - Other

Methods - Processor

Constructors

  • Creates a new instance from boolean.

    Since

    1.0.15

    Example

    const koconutBoolean = await new KoconutBoolean(true)
    // ↑ This is a KoconutBoolean instance, of which value is true.

    const koconutBoolean = await new KoconutBoolean()
    // ↑ This is a KoconutBoolean instance, of which value is false.

    Parameters

    • boolean: null | boolean = null

      A boolean value which is either true or false. If it's omitted false is default value.

    Returns KoconutBoolean

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<boolean>

      A callback function that accepts an argument.

    Returns Promise<null | boolean>

  • 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<boolean, 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<boolean>

Generated using TypeDoc