Options
All
  • Public
  • Public/Protected
  • All
Menu

Class KoconutEntry<KeyType, ValueType>

Koconut Wrapper class for Entry.

see
-- Base --
Entry, Pair, KoconutPair

-- Container --
KoconutMap

-- Protocol --
KoconutEquatable

Type parameters

  • KeyType

    Check for Entry.

  • ValueType

    Check for Entry.

Hierarchy

  • KoconutPrimitive<Entry<KeyType, ValueType>>
    • KoconutEntry

Implements

Index

Constructors

Other Methods

Processor Methods

Constructors

constructor

  • new KoconutEntry(key?: KeyType | null, value?: ValueType | null): KoconutEntry

Other Methods

equalsTo

Processor Methods

also

  • also(block: (data: Entry<KeyType, ValueType>) => void | Promise<void>): Promise<Entry<KeyType, ValueType> | null>
  • 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: (data: Entry<KeyType, ValueType>) => void | Promise<void>

      A callback function that accepts an argument.

        • (data: Entry<KeyType, ValueType>): void | Promise<void>
        • Parameters

          • data: Entry<KeyType, ValueType>

          Returns void | Promise<void>

    Returns Promise<Entry<KeyType, ValueType> | null>

let

  • let<ReturnType>(block: (data: Entry<KeyType, ValueType>) => ReturnType | Promise<ReturnType>): Promise<ReturnType>
  • 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: (data: Entry<KeyType, ValueType>) => ReturnType | Promise<ReturnType>

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

        • (data: Entry<KeyType, ValueType>): ReturnType | Promise<ReturnType>
        • Parameters

          • data: Entry<KeyType, ValueType>

          Returns ReturnType | Promise<ReturnType>

    Returns Promise<ReturnType>

process

  • process(): Promise<void>
  • 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>

retrieve

yield

  • yield(): Promise<Entry<KeyType, ValueType>>
  • 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<Entry<KeyType, ValueType>>

Generated using TypeDoc