From a8f986af52af5425f00ec429bcb3dbe60019bb7d Mon Sep 17 00:00:00 2001 From: ApexCaptain Date: Wed, 22 Dec 2021 16:12:11 +0900 Subject: [PATCH] New version released : 1.0.165 --- .github/workflows/pipeline.yml | 1 - docs/classes/Entry.html | 16 +- docs/classes/KoconutArray.html | 188 +++++++++--------- docs/classes/KoconutBoolean.html | 14 +- docs/classes/KoconutConflictException.html | 2 +- docs/classes/KoconutEntry.html | 14 +- .../KoconutIndexOutOfBoundsException.html | 2 +- .../KoconutInvalidArgumentException.html | 2 +- docs/classes/KoconutMap.html | 130 ++++++------ .../KoconutNoSuchElementException.html | 2 +- docs/classes/KoconutOption.html | 2 +- docs/classes/KoconutPair.html | 14 +- docs/classes/KoconutSet.html | 188 +++++++++--------- docs/classes/Pair.html | 16 +- docs/classes/Reference.KoconutCollection.html | 112 +++++------ docs/classes/Reference.KoconutError.html | 2 +- docs/classes/Reference.KoconutIterable.html | 66 +++--- docs/classes/Reference.KoconutPrimitive.html | 8 +- docs/classes/Reference.Sequence.html | 2 +- .../coverage/components/KoconutOption.ts.html | 2 +- .../components/KoconutPrimitive.ts.html | 2 +- .../callback/KoconutCallbacks.ts.html | 2 +- docs/coverage/components/callback/index.html | 2 +- .../container/KoconutIterable.ts.html | 2 +- .../collection/KoconutCollection.ts.html | 2 +- .../collection/array/KoconutArray.ts.html | 2 +- .../container/collection/array/index.html | 2 +- .../container/collection/index.html | 2 +- .../collection/set/KoconutSet.ts.html | 2 +- .../container/collection/set/index.html | 2 +- docs/coverage/components/container/index.html | 2 +- .../container/map/KoconutMap.ts.html | 2 +- .../components/container/map/index.html | 2 +- .../components/enum/KoconutLocale.ts.html | 2 +- .../components/enum/KoconutLoopSignal.ts.html | 2 +- docs/coverage/components/enum/index.html | 2 +- .../exception/KoconutExceptions.ts.html | 2 +- docs/coverage/components/exception/index.html | 2 +- docs/coverage/components/index.html | 2 +- docs/coverage/index.html | 2 +- docs/enums/KoconutLocale.html | 2 +- docs/enums/KoconutLoopSignal.html | 2 +- docs/interfaces/KoconutComparable.html | 2 +- docs/interfaces/KoconutEquatable.html | 2 +- docs/interfaces/Reference.KoconutOpener.html | 2 +- .../Reference.KoconutYieldable.html | 2 +- docs/modules/KoconutLocale.html | 2 +- docs/modules/Reference.html | 2 +- package.json | 2 +- 49 files changed, 420 insertions(+), 421 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 0c5fa19..7ff8b20 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -19,7 +19,6 @@ jobs: windows-2022, windows-latest, # Mac - macos-11, macos-latest, ] # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#github-hosted-runners node-version: [12.x, 13.x, 14.x, 15.x, 16.x] diff --git a/docs/classes/Entry.html b/docs/classes/Entry.html index baf0939..1fbc921 100644 --- a/docs/classes/Entry.html +++ b/docs/classes/Entry.html @@ -20,19 +20,19 @@

The type of the key value.

  • ValueType

    The type of the value.

    -
  • Hierarchy

    Implements

    Index

    Constructors

    constructor

    • new Entry<KeyType, ValueType>(keyElement: KeyType, valueElement: ValueType): Entry<KeyType, ValueType>

    Hierarchy

    • Entry

    Implements

    Index

    Constructors

    constructor

    • new Entry<KeyType, ValueType>(keyElement: KeyType, valueElement: ValueType): Entry<KeyType, ValueType>

    Accessors

    key

    • get key(): KeyType

    Returns Entry<KeyType, ValueType>

    Accessors

    key

    • get key(): KeyType

    value

    • get value(): ValueType

    value

    • get value(): ValueType

    Methods

    equalsTo

    Methods

    equalsTo

    toArray

    • toArray(): [KeyType, ValueType]

    Returns boolean | KoconutBoolean

    toArray

    • toArray(): [KeyType, ValueType]

    toPair

    • toPair(): Pair<KeyType, ValueType>

    toPair

    • toPair(): Pair<KeyType, ValueType>

    toString

    • toString(): string

    toString

    • toString(): string
    • Turns this Entry into a simple JSON object string.

      example
      const myEntry = Entry.from(["Apex", "Captain"])
      console.log(myEntry.toString()) // Or, you can use console.log(`${myEntry}`)
      // ↑ {"keyElement":'Apex',"valueElement":"Captain"}
      -

      Returns string

    Static from

    • from<KeyType, ValueType>(entry: [KeyType, ValueType]): Entry<KeyType, ValueType>

    Static from

    • from<KeyType, ValueType>(entry: [KeyType, ValueType]): Entry<KeyType, ValueType>

    Returns KoconutPrimitive<ResultDataType>

    foldIndexed

    • foldIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutPrimitive<ResultDataType>

    Returns KoconutPrimitive<ResultDataType>

    foldIndexed

    • foldIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutPrimitive<ResultDataType>
    • Accumulates value starting with initial value and applying operation from left to right to current accumulator value and each element.

      since

      1.0.10

      @@ -31,7 +31,7 @@ previously returned in the last invocation of the callback or initial value. The method calls the operation one time for each element and index in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the operation. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<ResultDataType>

    Calculator Methods

    count

    Returns KoconutPrimitive<ResultDataType>

    Calculator Methods

    count

    • Returns the number of the elements matching the given predicate. If the predicate is ommitted it'll returns the whole number of elements.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const numberOfAllArrayElements = await koconutArray
      .count()
      .yield()
      console.log(numberOfAllArrayElements)
      // ↑ 5

      const numberOfArrayElementsHigherThan2 = await koconutArray
      .count(eachNumber => eachNumber > 2)
      .yield()
      console.log(numberOfArrayElementsHigherThan2)
      // ↑ 3 -- i.e. [3, 4, 5]

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const numberOfAllSetElements = await koconutSet
      .count()
      .yield()
      console.log(numberOfAllSetElements)
      // ↑ 5

      const numberOfOddSetElements = await koconutSet
      .count(eachNumber => eachNumber % 2 == 1)
      .yield()
      console.log(numberOfOddSetElements)
      // ↑ 3 -- i.e. [1, 3, 5]

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3)
      .associateWith(eachNumber => eachNumber * 2)
      // ↑ Map { 1 => 2,
      // 2 => 4,
      // 3 => 6 }

      const numberOfAllMapEntries = await koconutMap
      .count()
      .yield()
      console.log(numberOfAllMapEntries)
      // ↑ 3

      const numberOfMapEntriesValueHigherThan5 = await koconutMap
      .count(eachEntry => eachEntry.value > 5)
      .yield()
      console.log(numberOfMapEntriesValueHigherThan5)
      // ↑ 1 -- i.e. Entry { 3, 6 }

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(1,2,3,4,5)

      const numberOfArrayElementsLessThan3 = await koconutArray2
      .count(async eachNumber => eachNumber < 3)
      .yield()
      console.log(numberOfArrayElementsLessThan3)
      // ↑ 2 -- i.e. [1, 2]

      const numberOfEvenArrayElements = await koconutArray2
      .count(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 2 == 0)
      }))
      .yield()
      console.log(numberOfEvenArrayElements)
      // ↑ 2 -- i.e. [2, 4] @@ -40,7 +40,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<number>

    maxBy

    Returns KoconutPrimitive<number>

    maxBy

    Returns KoconutPrimitive<DataType>

    maxByOrNull

    Returns KoconutPrimitive<DataType>

    maxByOrNull

    • Returns the first element yielding the largest value of the given function or null if there are no elements.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const largestNumberOfArray = await koconutArray
      .maxByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(largestNumberOfArray)
      // ↑ 5


      const largestNumberOfEmptyArray = await koconutArray
      .filter(eachNumber => eachNumber > 10)
      .maxByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(largestNumberOfEmptyArray)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of("a", "ab", "abc")

      const longestStringOfSet = await koconutSet
      .maxByOrNull(eachString => eachString.length)
      .yield()
      console.log(longestStringOfSet)
      // ↑ abc

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1, 12, 123)
      .associateWith(eachNumber => eachNumber.toString())

      const longestDigitsEntryOfMap = await koconutMap
      .maxByOrNull(eachEntry => eachEntry.value.length)
      .yield()
      console.log(longestDigitsEntryOfMap)
      // ↑ Entry { keyElement: 123, valueElement: '123' }

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(19,27,32)

      const largestNumberOfArray2 = await koconutArray2
      .maxByOrNull(async eachNumber => eachNumber)
      .yield()
      console.log(largestNumberOfArray2)
      // ↑ 32

      const largest1sDigitNumberOfArray2 = await koconutArray2
      .maxByOrNull(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 10)
      }))
      .yield()
      console.log(largest1sDigitNumberOfArray2)
      // ↑ 19 @@ -61,7 +61,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    maxOf

    • maxOf<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutPrimitive<null | DataType>

    maxOf

    • maxOf<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    maxOfOrNull

    • maxOfOrNull<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    maxOfOrNull

    • maxOfOrNull<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>
    • Returns the largest value among all values produced by selector function applied to each element in the collection or null if there are no elements.

      since

      1.0.10

      @@ -82,7 +82,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | string | number | ComparableType>

    maxOfWith

    • maxOfWith<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>

    Returns KoconutPrimitive<null | string | number | ComparableType>

    maxOfWith

    • maxOfWith<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>
    • Returns the largest value according to the provided comparator among all values produced by selector function applied to each element in the collection all throws KoconutNoSuchElementException if elements are empty.

      @@ -99,7 +99,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<ResultDataType>

    maxOfWithOrNull

    • maxOfWithOrNull<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>

    Returns KoconutPrimitive<ResultDataType>

    maxOfWithOrNull

    • maxOfWithOrNull<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>
    • Returns the largest value according to the provided comparator among all values produced by selector function applied to each element in the collection or null if elements are empty.

      @@ -115,7 +115,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | ResultDataType>

    maxWith

    Returns KoconutPrimitive<null | ResultDataType>

    maxWith

    Returns KoconutPrimitive<DataType>

    maxWithOrNull

    Returns KoconutPrimitive<DataType>

    maxWithOrNull

    • Returns the first element having the largest value according to the provided comparator or null if elements are empty.

      since

      1.0.10

      @@ -138,7 +138,7 @@ In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.

    • thisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    minBy

    Returns KoconutPrimitive<null | DataType>

    minBy

    Returns KoconutPrimitive<DataType>

    minByOrNull

    Returns KoconutPrimitive<DataType>

    minByOrNull

    • Returns the first element yielding the smallest value of the given function or null if there are no elements.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const smallestNumberOfArray = await koconutArray
      .minByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(smallestNumberOfArray)
      // ↑ 1

      const smallestNumberOfEmptyArray = await koconutArray
      .filter(eachNumber => eachNumber > 10)
      .minByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(smallestNumberOfEmptyArray)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of("a", "ab", "abc")

      const shortestStringOfSet = await koconutSet
      .minByOrNull(eachString => eachString.length)
      .yield()
      console.log(shortestStringOfSet)
      // ↑ a

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1, 12, 123)
      .associateWith(eachNumber => eachNumber.toString())

      const shortestDigitsEntryOfMap = await koconutMap
      .minByOrNull(eachEntry => eachEntry.value.length)
      .yield()
      console.log(shortestDigitsEntryOfMap)
      // ↑ Entry { keyElement: 1, valueElement: '1' }

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(19,27,32)

      const smallestNumberOfArray2 = await koconutArray2
      .minByOrNull(async eachNumber => eachNumber)
      .yield()
      console.log(smallestNumberOfArray2)
      // ↑ 19

      const smallest1sDigitNumberOfArray2 = await koconutArray2
      .minByOrNull(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 10)
      }))
      .yield()
      console.log(smallest1sDigitNumberOfArray2)
      // ↑ 32 @@ -159,7 +159,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    minOf

    • minOf<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutPrimitive<null | DataType>

    minOf

    • minOf<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    minOfOrNull

    • minOfOrNull<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    minOfOrNull

    • minOfOrNull<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>
    • Returns the smallest value among all values produced by selector function applied to each element in the collection or null if there are no elements.

      since

      1.0.10

      @@ -180,7 +180,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | string | number | ComparableType>

    minOfWith

    • minOfWith<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>

    Returns KoconutPrimitive<null | string | number | ComparableType>

    minOfWith

    • minOfWith<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>
    • Returns the smallest value according to the provided comparator among all values produced by selector function applied to each element in the collection all throws KoconutNoSuchElementException if elements are empty.

      @@ -197,7 +197,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<ResultDataType>

    minOfWithOrNull

    • minOfWithOrNull<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>

    Returns KoconutPrimitive<ResultDataType>

    minOfWithOrNull

    • minOfWithOrNull<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>
    • Returns the smallest value according to the provided comparator among all values produced by selector function applied to each element in the collection all null if elements are empty.

      @@ -214,7 +214,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | ResultDataType>

    minWith

    Returns KoconutPrimitive<null | ResultDataType>

    minWith

    Returns KoconutPrimitive<DataType>

    minWithOrNull

    Returns KoconutPrimitive<DataType>

    minWithOrNull

    • Returns the first element having the smallest value according to the provided comparator or null if elements are empty.

      since

      1.0.10

      @@ -237,24 +237,24 @@ In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.

    • thisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    Caster Methods

    asArray

    Returns KoconutPrimitive<null | DataType>

    Caster Methods

    asArray

    • Creates an KoconutArray instance that wraps original data.

      since

      1.0.13

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const arrToArr = await koconutArray
      .asArray()
      .yield()
      console.log(arrToArr)
      // ↑ [ 1, 2, 3, 4, 5 ]

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,1,2,2,3,3,4,4,5,5)

      const setToArr = await koconutSet
      .asArray()
      .yield()
      console.log(setToArr)
      // ↑ [ 1, 2, 3, 4, 5 ]

      // Case 3 -- KoconutFlow
      const koconutFlow = KoconutFlow.ofSimple(1,2,3,4,5)

      const flowToArr = await koconutFlow
      .asArray()
      .yield()
      console.log(flowToArr)
      // ↑
      // [
      // Entry { keyElement: 0, valueElement: 1 },
      // Entry { keyElement: 1, valueElement: 2 },
      // Entry { keyElement: 2, valueElement: 3 },
      // Entry { keyElement: 3, valueElement: 4 },
      // Entry { keyElement: 4, valueElement: 5 }
      // ]

      // Case 4 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber])

      const mapToArr = await koconutMap
      .asArray()
      .yield()
      console.log(mapToArr)
      // ↑
      // [
      // Entry { keyElement: 1, valueElement: 1 },
      // Entry { keyElement: 2, valueElement: 2 },
      // Entry { keyElement: 3, valueElement: 3 },
      // Entry { keyElement: 4, valueElement: 4 },
      // Entry { keyElement: 5, valueElement: 5 }
      // ]
      -

      Returns KoconutArray<DataType>

    asSet

    asSet

    • Creates an KoconutSet instance that wraps original data.

      since

      1.0.13

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const arrToSet = await koconutArray
      .asSet()
      .yield()
      console.log(arrToSet)
      // ↑ Set { 1, 2, 3, 4, 5 }

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,1,2,2,3,3,4,4,5,5)

      const setToSet = await koconutSet
      .asSet()
      .yield()
      console.log(setToSet)
      // ↑ Set { 1, 2, 3, 4, 5 }

      // Case 3 -- KoconutFlow
      const koconutFlow = KoconutFlow.ofSimple(1,2,3,4,5)

      const flowToSet = await koconutFlow
      .asSet()
      .yield()
      console.log(flowToSet)
      // ↑
      // Set {
      // Entry { keyElement: 0, valueElement: 1 },
      // Entry { keyElement: 1, valueElement: 2 },
      // Entry { keyElement: 2, valueElement: 3 },
      // Entry { keyElement: 3, valueElement: 4 },
      // Entry { keyElement: 4, valueElement: 5 }
      // }

      // Case 4 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber])

      const mapToSet = await koconutMap
      .asSet()
      .yield()
      console.log(mapToSet)
      // ↑
      // Set {
      // Entry { keyElement: 1, valueElement: 1 },
      // Entry { keyElement: 2, valueElement: 2 },
      // Entry { keyElement: 3, valueElement: 3 },
      // Entry { keyElement: 4, valueElement: 4 },
      // Entry { keyElement: 5, valueElement: 5 }
      // }
      -

      Returns KoconutSet<DataType>

    Creator Methods

    Static from

    • from<DataType>(source?: null | Iterable<DataType>): KoconutArray<DataType>

    Creator Methods

    Static from

    • from<DataType>(source?: null | Iterable<DataType>): KoconutArray<DataType>
    • Creates a new instance from iterable object.

      since

      1.0.11

      example
      const numbers = Array.of(1,2,3,4,5)
      const koconutNumbers = KoconutArray.from(numbers)
      // ↑ This is a Koconut number array consists of 1 to 5.

      const emptyNumberArray = KoconutArray.from<number>()
      // ↑ This is an empty Koconut number array.

      Type parameters

      • DataType

      Parameters

      • source: null | Iterable<DataType> = null

        An array-like iterable object to convert to a KoconutArray.

        -

      Returns KoconutArray<DataType>

    Static generate

    Returns KoconutArray<DataType>

    Static generate

    • Creates a new instance with given count as number of values. count cannot be negative number. Each value is provided from generator with given ordered index.

      throws

      KoconutInvalidArgumentException @@ -268,14 +268,14 @@

      A callback function that accepts an argument. The method calls the action one time for each ordered index.

    • thisArg: any = null

      An object to which the this keyword can refer in the generator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    Static of

    Returns KoconutArray<DataType>

    Static of

    • Creates a new instance from variable number of arguments.

      since

      1.0.11

      example
      const koconutNumbers = KoconutArray.of(1,2,3,4,5)
      // ↑ This is a Koconut number array consists of 1 to 5.

      const emptyNumberArray = KoconutArray.of<number>()
      // ↑ This is an empty Koconut number array.

      Type parameters

      • DataType

      Parameters

      • Rest ...data: DataType[]

        A set of elements to include in the new KoconutArray object.

        -

      Returns KoconutArray<DataType>

    Inspector Methods

    all

    Returns KoconutArray<DataType>

    Inspector Methods

    all

    • Return true if all elements match te given predicate.

      since

      1.0.10

      example
        // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const areAllArrayElementsGreaterThan0 = await koconutArray
      .all(eachNumber => eachNumber > 0)
      .yield()
      console.log(areAllArrayElementsGreaterThan0)
      // ↑ true

      const areAllArrayElementsEven = await koconutArray
      .all(eachNumber => eachNumber % 2 == 0)
      .yield()
      console.log(areAllArrayElementsEven)
      // ↑ false -- i.e. '1' is not an even number.


      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const areAllSetElementsGreaterThan0 = await koconutSet
      .all(eachNumber => eachNumber > 0)
      .yield()
      console.log(areAllSetElementsGreaterThan0)
      // ↑ true

      const areAllSetElementsOdd = await koconutSet
      .all(eachNumber => eachNumber % 2 == 1)
      .yield()
      console.log(areAllSetElementsOdd)
      // ↑ false -- i.e. '2' is not an odd number.


      // Case 3 -- KoconutMap
      const koconutMap = KoconutMap.of(
      [0, 0],
      [1, 1],
      [2, 2]
      )

      const areAllMapEntriesKeyEqualsToValue = await koconutMap
      .all(eachEntry => eachEntry.key == eachEntry.value)
      .yield()
      console.log(areAllMapEntriesKeyEqualsToValue)
      // ↑ true

      const areAllMapEntriesSumGreaterThan3 = await koconutMap
      .all(eachEntry => eachEntry.key + eachEntry.value > 3)
      .yield()
      console.log(areAllMapEntriesSumGreaterThan3)
      // ↑ false -- i.e. Sum of key and value of first Entry { 0, 0 } is 0.
      // It's definetly less than 3

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(1,2,3,4,5)

      const areAllArrayElementsLessThan10 = await koconutArray2
      .all(async eachNumber => eachNumber < 10)
      .yield()
      console.log(areAllArrayElementsLessThan10)
      // ↑ true

      const areAllArrayElementsOdd = await koconutArray2
      .all(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 2 == 1)
      }))
      .yield()
      console.log(areAllArrayElementsOdd)
      // ↑ false -- i.e. '2' is not an odd number. @@ -284,7 +284,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutBoolean

    any

    Returns KoconutBoolean

    any

    • Returns true if the collection has at least one element matches the given predicate.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isAnyArrayElementGreaterThan4 = await koconutArray
      .any(eachNumber => eachNumber > 4)
      .yield()
      console.log(isAnyArrayElementGreaterThan4)
      // ↑ true -- i.e. '5' is greater than 4.

      const isAnyArrayElementMultipleOf6 = await koconutArray
      .any(eachNumber => eachNumber % 6 == 0)
      .yield()
      console.log(isAnyArrayElementMultipleOf6)
      // ↑ false

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isAnySetElementGreaterThan3 = await koconutSet
      .any(eachNumber => eachNumber > 3)
      .yield()
      console.log(isAnySetElementGreaterThan3)
      // ↑ true -- i.e. '4' is greater than 3.

      const isAnySetElementLessThan0 = await koconutSet
      .any(eachNumber => eachNumber < 0)
      .yield()
      console.log(isAnySetElementLessThan0)
      // ↑ false

      // Case 3 -- KoconutMap
      const koconutMap = KoconutMap.of(
      [0, 0],
      [1, 1],
      [2, 2]
      )

      const isAnyMapEntrySumGreaterThan3 = await koconutMap
      .any(eachEntry => eachEntry.key + eachEntry.value > 3)
      .yield()
      console.log(isAnyMapEntrySumGreaterThan3)
      // ↑ true -- i.e. Sum of key and value of third Entry { 2, 2 } is 4.
      // It's grater than 4.

      const isAnyMapEntryKeyMultipleOf4 = await koconutMap
      .any(eachEntry => eachEntry.key > 0 && eachEntry.key % 4 == 0)
      .yield()
      console.log(isAnyMapEntryKeyMultipleOf4)
      // ↑ false

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(1,2,3,4,5)

      const isAnyArrayElementLessThan2 = await koconutArray2
      .any(async eachNumber => eachNumber < 2)
      .yield()
      console.log(isAnyArrayElementLessThan2)
      // ↑ true -- i.e. '1' is less than 2.

      const isAnyArrayElementGreaterThan7 = await koconutArray2
      .any(eachNumber => new Promise(resolve => {
      resolve(eachNumber > 7)
      }))
      .yield()
      console.log(isAnyArrayElementGreaterThan7)
      // ↑ false @@ -293,38 +293,38 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutBoolean

    contains

    Returns KoconutBoolean

    contains

    • Checks if the specified element is contained in this collection.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const doesArrayContain3 = await koconutArray
      .contains(3)
      .yield()
      console.log(doesArrayContain3)
      // ↑ true

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const doesSetContains6 = await koconutSet
      .contains(6)
      .yield()
      console.log(doesSetContains6)
      // ↑ false

      Parameters

      • element: DataType

        The element to search for.

        -

      Returns KoconutBoolean

    containsAll

    Returns KoconutBoolean

    containsAll

    • Checks if all the elements are contained in this collection.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const doesArrayContain1to3 = await koconutArray
      .containsAll([1,2,3])
      .yield()
      console.log(doesArrayContain1to3)
      // ↑ true

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const doesSetContains5to6 = await koconutSet
      .containsAll([5,6,7])
      .yield()
      console.log(doesSetContains5to6)
      // ↑ false

      Parameters

      • elements: Iterable<DataType>

        The elements to search for.

        -

      Returns KoconutBoolean

    isEmpty

    Returns KoconutBoolean

    isEmpty

    • Returns true if the collection is empty (contains no elements), false otherwise.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isNumberArrayEmpty = await koconutArray
      .isEmpty()
      .yield()
      console.log(isNumberArrayEmpty)
      // ↑ false

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isFilteredNumberSetEmpty = await koconutSet
      .filter(eachNumber => eachNumber > 10)
      .isEmpty()
      .yield()
      console.log(isFilteredNumberSetEmpty)
      // ↑ true

      // Case 3 -- KoconutMap
      const koconutMap = new KoconutMap<number, number>()

      const isNumberPairedMapEmpty = await koconutMap
      .isEmpty()
      .yield()
      console.log(isNumberPairedMapEmpty)
      // ↑ true
      -

      Returns KoconutBoolean

    isNotEmpty

    isNotEmpty

    • Returns true if the collection is not empty.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isNumberArrayEmpty = await koconutArray
      .isNotEmpty()
      .yield()
      console.log(isNumberArrayEmpty)
      // ↑ true

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isFilteredNumberSetEmpty = await koconutSet
      .filter(eachNumber => eachNumber > 10)
      .isNotEmpty()
      .yield()
      console.log(isFilteredNumberSetEmpty)
      // ↑ false

      // Case 3 -- KoconutMap
      const koconutMap = new KoconutMap<number, number>()

      const isNumberPairedMapEmpty = await koconutMap
      .isNotEmpty()
      .yield()
      console.log(isNumberPairedMapEmpty)
      // ↑ false
      -

      Returns KoconutBoolean

    isNullOrEmpty

    isNullOrEmpty

    • Returns true if this nullable collection is either null or empty.

      since

      1.0.10

      deprecated

      Use isEmpty instead.

      until

      1.3.0

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isNumberArrayEmpty = await koconutArray
      .isNullOrEmpty()
      .yield()
      console.log(isNumberArrayEmpty)
      // ↑ false

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isFilteredNumberSetEmpty = await koconutSet
      .filter(eachNumber => eachNumber > 10)
      .isNullOrEmpty()
      .yield()
      console.log(isFilteredNumberSetEmpty)
      // ↑ true

      // Case 3 -- KoconutMap
      const koconutMap = new KoconutMap<number, number>()

      const isNumberPairedMapEmpty = await koconutMap
      .isNullOrEmpty()
      .yield()
      console.log(isNumberPairedMapEmpty)
      // ↑ true
      -

      Returns KoconutBoolean

    none

    none

    • predicate callback function is optional. If it's omitted the method returns true if the collection has no elements. Otherwise, returns true if no elements match the given predicate.

      since

      1.0.10

      @@ -334,7 +334,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutBoolean

    Iterator Methods

    forEach

    Returns KoconutBoolean

    Iterator Methods

    forEach

    • Performs the given action on each element. When you want to stop iteration in the meantime return false or KoconutLoopSignal.BREAK.

      since

      1.0.10

      @@ -344,7 +344,7 @@

      A callback function that accepts an argument. The method calls the action one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the action. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<void>

    forEachIndexed

    Returns KoconutPrimitive<void>

    forEachIndexed

    • Performs the given action on each element, providing sequential index with the element. When you want to stop iteration in the meantime return false or KoconutLoopSignal.BREAK.

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5,6,7)

      await koconutArray
      .forEachIndexed(console.log)
      // ↑ 0 1
      // 1 2
      // 2 3
      // 3 4
      // 4 5
      // 5 6
      // 6 7
      .process()

      await koconutArray
      .forEachIndexed((eachIndex, eachNumber) => {
      if(eachIndex == 3) return KoconutLoopSignal.BREAK
      console.log(eachNumber)
      })
      // ↑ 1 2 3 -- i.e. Since when the index is '3', the loop is interrupted.
      // The last printed number(element) would be '3'.
      .process()

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,1,2,3)

      await koconutSet
      .forEachIndexed(console.log)
      // ↑ 0 1
      // 1 2
      // 2 3
      .process()

      await koconutSet
      .forEachIndexed((eachIndex, eachNumber) => {
      if(eachIndex != 0 && eachIndex % 2 == 0) return false
      console.log(eachNumber)
      })
      // ↑ 1 2 -- i.e. Since when the index '2', it's an even number.
      // So the loop is interrupted.
      // The last printed number(element) would be '2'
      .process()

      // Case 3 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(1,2,3)

      await koconutArray2
      .forEachIndexed(async (eachIndex, eachNumber) =>
      console.log(eachIndex, eachNumber))
      // ↑ 0 1
      // 1 2
      // 2 3
      .process()

      await koconutArray2
      .forEachIndexed(async (eachIndex, eachNumber) => new Promise(resolve => {
      resolve(console.log(eachIndex, eachNumber))
      }))
      // ↑ 0 1
      // 1 2
      // 2 3
      .process() @@ -353,7 +353,7 @@

      A callback function that accepts two arguments. The method calls the action one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the action. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<void>

    onEach

    Returns KoconutPrimitive<void>

    onEach

    • Perfroms the given action on each element and returns the original collection itself afterwards. When you want to stop iteration in the meantime return false or KoconutLoopSignal.BREAK.

      since

      1.0.10

      @@ -363,7 +363,7 @@

      A callback function that accepts an argument. The method calls the action one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the action. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    onEachIndexed

    Returns KoconutArray<DataType>

    onEachIndexed

    • Performs the given action on each element, providing sequential index with the element, and returns the collection itself afterwards. When you want to stop iteration in the meantime return false or KoconutLoopSignal.BREAK.

      since

      1.0.10

      @@ -373,14 +373,14 @@

      A callback function that accepts two arguments. The method calls the action one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the action. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    Manipulator Methods

    distinct

    Returns KoconutArray<DataType>

    Manipulator Methods

    distinct

    • Returns a KoconutArray containing only distinct elements from this collection. If the type of data is a simple number or string, the method will check equality by using '==' operator, but if it's not, you'd better make your custom class inherits KoconutEquatable.

      since

      1.0.10

      example
      const numberKoconutArray = KoconutArray.of(1,1,2,2,3,3)

      const distinctNumbers = await numberKoconutArray
      .distinct()
      .yield()
      console.log(distinctNumbers)
      // ↑ [ 1, 2, 3 ]

      class SomeInfo {
      info : string
      constructor(info : string) {
      this.info = info
      }
      }
      const someInfoKoconutArray = KoconutArray.of(
      new SomeInfo("A"),
      new SomeInfo("A"),
      new SomeInfo("B"),
      new SomeInfo("B"),
      new SomeInfo("C"),
      new SomeInfo("C"),
      )
      const distinctSomeInfos = await someInfoKoconutArray
      .distinct()
      .yield()
      console.log(distinctSomeInfos)
      // ↑ [
      // SomeInfo { info: 'A' },
      // SomeInfo { info: 'A' },
      // SomeInfo { info: 'B' },
      // SomeInfo { info: 'B' },
      // SomeInfo { info: 'C' },
      // SomeInfo { info: 'C' }
      // ]

      class SomeEquatableInfo implements KoconutEquatable {
      info : string
      constructor(info : string) {
      this.info = info
      }
      equalsTo(other : SomeEquatableInfo) : boolean {
      return this.info == other.info
      }
      }
      const someEquatableInfoKoconutArray = KoconutArray.of(
      new SomeEquatableInfo("A"),
      new SomeEquatableInfo("A"),
      new SomeEquatableInfo("B"),
      new SomeEquatableInfo("B"),
      new SomeEquatableInfo("C"),
      new SomeEquatableInfo("C")
      )
      const distinctSomeEquatableInfos = await someEquatableInfoKoconutArray
      .distinct()
      .yield()
      console.log(distinctSomeEquatableInfos)
      // ↑ [
      // SomeEquatableInfo { info: 'A' },
      // SomeEquatableInfo { info: 'B' },
      // SomeEquatableInfo { info: 'C' }
      // ]
      -

      Returns KoconutArray<DataType>

    distinctBy

    • distinctBy<KeyType, EquatableKeyType>(selector: Selector<DataType, KeyType | EquatableKeyType>, thisArg?: any): KoconutArray<DataType>

    distinctBy

    • distinctBy<KeyType, EquatableKeyType>(selector: Selector<DataType, KeyType | EquatableKeyType>, thisArg?: any): KoconutArray<DataType>
    • Returns a KoconutArray containing only elements from the given collection having distinct keys returned by the given selector function.

      since

      1.0.10

      @@ -390,21 +390,21 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value

      -

    Returns KoconutArray<DataType>

    drop

    Returns KoconutArray<DataType>

    drop

    dropLast

    Returns KoconutArray<DataType>

    dropLast

    dropLastWhile

    Returns KoconutArray<DataType>

    dropLastWhile

    • Returns a KoconutArray containing all elements except last elements that satisfy the given predicate.

      since

      1.0.10

      example
      const koconutArray = KoconutArray.of(
      1,2,3,4,5,6,7,8,9,10
      )

      const greaterThan5DroppedArray = await koconutArray
      .dropLastWhile(eachNumber => eachNumber > 5)
      .yield()
      console.log(greaterThan5DroppedArray)
      // ↑ [ 1, 2, 3, 4, 5 ] @@ -413,7 +413,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    dropWhile

    Returns KoconutArray<DataType>

    dropWhile

    • Returns a KoconutArray containing all elements except first elements that satisfy the given predicate.

      since

      1.0.10

      example
      const koconutArray = KoconutArray.of(
      1,2,3,4,5,6,7,8,9,10
      )

      const lessThan5DroppedArray = await koconutArray
      .dropWhile(eachNumber => eachNumber < 5)
      .yield()
      console.log(lessThan5DroppedArray)
      // ↑ [ 5, 6, 7, 8, 9, 10 ] @@ -422,7 +422,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    filter

    Returns KoconutArray<DataType>

    filter

    • Returns a KoconutArray containing only elements matching the given predicate.

      since

      1.0.10

      example
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const evenNumbers = await koconutArray
      .filter(eachNumber => eachNumber % 2 == 0)
      .yield()
      console.log(evenNumbers)
      // ↑ [ 2, 4 ] @@ -431,7 +431,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    filterIndexed

    Returns KoconutArray<DataType>

    filterIndexed

    • Returns a KoconutArray containing only elements matching the given predicate with indexes.

      since

      1.0.10

      example
      const koconutArray = KoconutArray.of(0,1,2,5,6,7)

      const numbersEqualToIndex = await koconutArray
      .filterIndexed((eachIndex, eachNumber) => eachIndex == eachNumber)
      .yield()
      console.log(numbersEqualToIndex)
      // ↑ [ 0, 1, 2 ] @@ -440,7 +440,7 @@

      A callback function that accepts two arguments. The method calls the predicate one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    filterIndexedTo

    Returns KoconutArray<DataType>

    filterIndexedTo

    • Appends all elements matching the given predicate with indexes to the given destination.

      since

      1.0.10

      example
      const koconutArray = KoconutArray.of(0,1,2,5,6,7)

      const numbersEqualToIndex = new Array<number>()
      const origianlData =await koconutArray
      .filterIndexedTo(
      numbersEqualToIndex,
      (eachIndex, eachNumber) => eachIndex == eachNumber
      )
      .yield()
      console.log(numbersEqualToIndex)
      // ↑ [ 0, 1, 2 ]
      console.log(origianlData)
      // ↑ [ 0, 1, 2, 5, 6, 7 ] @@ -451,7 +451,7 @@

      A callback function that accepts two arguments. The method calls the predicate one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    filterNot

    Returns KoconutArray<DataType>

    filterNot

    • Returns a KoconutArray containing only elements not matching the given predicate.

      since

      1.0.10

      example
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const oddNumbers = await koconutArray
      .filterNot(eachNumber => eachNumber % 2 == 0)
      .yield()
      console.log(oddNumbers)
      // ↑ [ 1, 3, 5 ] @@ -460,19 +460,19 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    filterNotNull

    Returns KoconutArray<DataType>

    filterNotNull

    filterNotNullTo

    • filterNotNullTo(destination: DataType[] | Set<DataType>): KoconutArray<DataType>

    filterNotNullTo

    • filterNotNullTo(destination: DataType[] | Set<DataType>): KoconutArray<DataType>
    • Appends all elements that are not null to the given destination.

      since

      1.0.10

      example
      const koconutArray = KoconutArray.of(1,2,null,null)

      const numbers = Array<number>()
      const originalData = await koconutArray
      .filterNotNullTo(numbers)
      .yield()
      console.log(numbers)
      // ↑ [ 1, 2 ]
      console.log(originalData)
      // ↑ [ 1, 2, null, null ]

      Parameters

      • destination: DataType[] | Set<DataType>

        Iterable destinaion. Array or Set to be exact.

        -

      Returns KoconutArray<DataType>

    filterNotTo

    • filterNotTo(destination: DataType[] | Set<DataType>, predicate: Predicator<DataType>, thisArg?: any): KoconutArray<DataType>

    Returns KoconutArray<DataType>

    filterNotTo

    • filterNotTo(destination: DataType[] | Set<DataType>, predicate: Predicator<DataType>, thisArg?: any): KoconutArray<DataType>
    • Appends all elements not matching the given predicate to the given destination.

      since

      1.0.10

      example
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const oddNumbers = new Array<number>()
      const originalData = await koconutArray
      .filterNotTo(
      oddNumbers,
      eachNumber => eachNumber % 2 == 0
      )
      .yield()
      console.log(oddNumbers)
      // ↑ [ 1, 3, 5 ]
      console.log(originalData)
      // ↑ [ 1, 2, 3, 4, 5 ] @@ -483,7 +483,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    filterTo

    • filterTo(destination: DataType[] | Set<DataType>, predicate: Predicator<DataType>, thisArg?: any): KoconutArray<DataType>

    Returns KoconutArray<DataType>

    filterTo

    • filterTo(destination: DataType[] | Set<DataType>, predicate: Predicator<DataType>, thisArg?: any): KoconutArray<DataType>
    • Appends all elements matching the given predicate to the given destination.

      since

      1.0.10

      example
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const evenNumbers = new Array<number>()
      const originalData = await koconutArray
      .filterTo(
      evenNumbers,
      eachNumber => eachNumber % 2 == 0
      )
      .yield()
      console.log(evenNumbers)
      // ↑ [ 2, 4 ]
      console.log(originalData)
      // ↑ [ 1, 2, 3, 4, 5 ] @@ -494,7 +494,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    sortedBy

    Returns KoconutArray<DataType>

    sortedBy

    Returns KoconutArray<DataType>

    sortedByDescending

    Returns KoconutArray<DataType>

    sortedByDescending

    • Returns a KoconutArray of all elements sorted descending according to natural sort order of the value returned by specified selector function. It could be either a number, string, or custom class that inherits KoconutComparable.

      @@ -517,7 +517,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value

      -

    Returns KoconutArray<DataType>

    sortedWith

    Returns KoconutArray<DataType>

    sortedWith

    Returns KoconutArray<DataType>

    take

    Returns KoconutArray<DataType>

    take

    takeLast

    Returns KoconutArray<DataType>

    takeLast

    takeLastWhile

    Returns KoconutArray<DataType>

    takeLastWhile

    • Returns a KoconutArray containing last elements satisfying the given predicate.

      since

      1.0.10

      example
      const koconutArray = KoconutArray.of(
      1,2,3,4,5,6,7,8,9,10
      )

      const lastNumbersWhileGreaterThan7 = await koconutArray
      .takeLastWhile(eachNumber => eachNumber >7)
      .yield()
      console.log(lastNumbersWhileGreaterThan7)
      // ↑ [ 8, 9, 10 ] @@ -551,7 +551,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    takeWhile

    Returns KoconutArray<DataType>

    takeWhile

    • Returns a KoconutArray containing first elements satisfying the given predicate.

      since

      1.0.10

      example
      const koconutArray = KoconutArray.of(
      1,2,3,4,5,6,7,8,9,10
      )

      const numbersWhileLessThan5 = await koconutArray
      .takeWhile(eachNumber => eachNumber < 5)
      .yield()
      console.log(numbersWhileLessThan5)
      // ↑ [ 1, 2, 3, 4 ] @@ -560,7 +560,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    Other Methods

    indices

    intersect

    • intersect(other: Iterable<DataType>): KoconutSet<DataType>

    join

    • join(separator?: string, prefix?: string, postfix?: string, limit?: number, truncated?: string, transform?: null | Transformer<DataType, any>, thisArg?: any): KoconutPrimitive<string>

    last

    lastIndexOf

    lastOrNull

    minus

    minusElement

    partition

    plus

    plusElement

    random

    randomOrNull

    reduce

    reduceIndexed

    reduceIndexedOrNull

    reduceOrNull

    reversed

    runningFold

    • runningFold<ResultDataType>(initial: ResultDataType, operation: Operator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    runningFoldIndexed

    • runningFoldIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    runningReduce

    runningReduceIndexed

    scan

    • scan<ResultDataType>(initial: ResultDataType, operation: Operator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    scanIndexed

    • scanIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    shuffled

    single

    singleOrNull

    size

    subtract

    • subtract(other: Iterable<DataType>): KoconutSet<DataType>

    sumBy

    union

    • union(other: Iterable<DataType>): KoconutSet<DataType>

    validate

    • validate(data: null | DataType[]): Promise<void>

    windowed

    • windowed<ResultDataType>(size: number, step: number, partialWindows: boolean, transform: null | Transformer<DataType[], ResultDataType>, thisArg: any): KoconutArray<DataType[] | ResultDataType>

    withIndex

    zip

    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: null | Zipper<DataType, OtherDataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType | Pair<DataType, OtherDataType>>
    • zip<OtherDataType>(other: Iterable<OtherDataType>): KoconutArray<Pair<DataType, OtherDataType>>
    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: Zipper<DataType, OtherDataType, ResultDataType>): KoconutArray<ResultDataType>
    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: Zipper<DataType, OtherDataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType>

    zipWithNext

    • zipWithNext<ResultDataType>(transform: null | Zipper<DataType, DataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType | Pair<DataType, DataType>>
    • zipWithNext(): KoconutArray<Pair<DataType, DataType>>
    • zipWithNext<ResultDataType>(transform: Zipper<DataType, DataType, ResultDataType>): KoconutArray<ResultDataType>
    • zipWithNext<ResultDataType>(transform: Zipper<DataType, DataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType>

    Processor Methods

    also

    • also(block: Processor<DataType[]>): Promise<null | DataType[]>

    Returns KoconutArray<DataType>

    Other Methods

    indices

    intersect

    • intersect(other: Iterable<DataType>): KoconutSet<DataType>

    join

    • join(separator?: string, prefix?: string, postfix?: string, limit?: number, truncated?: string, transform?: null | Transformer<DataType, any>, thisArg?: any): KoconutPrimitive<string>

    last

    lastIndexOf

    lastOrNull

    minus

    minusElement

    partition

    plus

    plusElement

    random

    randomOrNull

    reduce

    reduceIndexed

    reduceIndexedOrNull

    reduceOrNull

    reversed

    runningFold

    • runningFold<ResultDataType>(initial: ResultDataType, operation: Operator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    runningFoldIndexed

    • runningFoldIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    runningReduce

    runningReduceIndexed

    scan

    • scan<ResultDataType>(initial: ResultDataType, operation: Operator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    scanIndexed

    • scanIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    shuffled

    single

    singleOrNull

    size

    subtract

    • subtract(other: Iterable<DataType>): KoconutSet<DataType>

    sumBy

    union

    • union(other: Iterable<DataType>): KoconutSet<DataType>

    validate

    • validate(data: null | DataType[]): Promise<void>

    windowed

    • windowed<ResultDataType>(size: number, step: number, partialWindows: boolean, transform: null | Transformer<DataType[], ResultDataType>, thisArg: any): KoconutArray<DataType[] | ResultDataType>

    withIndex

    zip

    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: null | Zipper<DataType, OtherDataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType | Pair<DataType, OtherDataType>>
    • zip<OtherDataType>(other: Iterable<OtherDataType>): KoconutArray<Pair<DataType, OtherDataType>>
    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: Zipper<DataType, OtherDataType, ResultDataType>): KoconutArray<ResultDataType>
    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: Zipper<DataType, OtherDataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType>

    zipWithNext

    • zipWithNext<ResultDataType>(transform: null | Zipper<DataType, DataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType | Pair<DataType, DataType>>
    • zipWithNext(): KoconutArray<Pair<DataType, DataType>>
    • zipWithNext<ResultDataType>(transform: Zipper<DataType, DataType, ResultDataType>): KoconutArray<ResultDataType>
    • zipWithNext<ResultDataType>(transform: Zipper<DataType, DataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType>

    Processor Methods

    also

    • also(block: Processor<DataType[]>): Promise<null | DataType[]>
    • 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

      @@ -568,7 +568,7 @@

      Parameters

      • block: Processor<DataType[]>

        A callback function that accepts an argument.

        -

      Returns Promise<null | DataType[]>

    let

    • let<ReturnType>(block: Selector<DataType[], ReturnType>): Promise<ReturnType>

    Returns Promise<null | DataType[]>

    let

    • let<ReturnType>(block: Selector<DataType[], 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.

      @@ -577,22 +577,22 @@

      Type parameters

      • ReturnType

      Parameters

      • block: Selector<DataType[], ReturnType>

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

        -

      Returns Promise<ReturnType>

    process

    • process(): Promise<void>

    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

    retrieve

    yield

    • yield(): Promise<DataType[]>

    yield

    • yield(): Promise<DataType[]>
    • 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<DataType[]>

    Selector Methods

    elementAt

    Selector Methods

    elementAt

    elementAtOrElse

    Returns KoconutPrimitive<DataType>

    elementAtOrElse

    • Returns an element at the given index or the result of calling the defaultValue function if the index is out of bounds of this collection.

      since

      1.0.10

      @@ -613,14 +613,14 @@

      A callback function that accepts an argument. The method calls the defaultValue function when index is out of bounds.

    • thisArg: any = null

      An object to which the this keyword can refer in the defaultValue. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<DataType>

    elementAtOrNull

    Returns KoconutPrimitive<DataType>

    elementAtOrNull

    • Returns an element at the given index or null if the index is out of bounds of this collection.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const elementAtIndex3OfArray = await koconutArray
      .elementAtOrNull(3)
      .yield()
      console.log(elementAtIndex3OfArray)
      // ↑ 4

      const elementAtIndex10OfArray = await koconutArray
      .elementAtOrNull(10)
      .yield()
      console.log(elementAtIndex10OfArray)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const elementAtIndex2OfSet = await koconutSet
      .elementAtOrNull(2)
      .yield()
      console.log(elementAtIndex2OfSet)
      // ↑ 3

      const elementAtIndexNegative2OfSet = await koconutSet
      .elementAtOrNull(-2)
      .yield()
      console.log(elementAtIndexNegative2OfSet)
      // ↑ null

      Parameters

      • index: number

        The index of element to search for.

        -

      Returns KoconutPrimitive<null | DataType>

    find

    Returns KoconutPrimitive<null | DataType>

    find

    • Returns the first element matching the given predicate, or null if no such element was found.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const foundEventNumberOfArray = await koconutArray
      .find(eachNumber => eachNumber % 2 == 0)
      .yield()
      console.log(foundEventNumberOfArray)
      // ↑ 2

      const foundMultiplesOf10Array = await koconutArray
      .find(eachNumber => eachNumber % 10 == 0)
      .yield()
      console.log(foundMultiplesOf10Array)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const foundOddNumberOfSet = await koconutSet
      .find(eachNumber => eachNumber % 2 == 1)
      .yield()
      console.log(foundOddNumberOfSet)
      // ↑ 1

      const foundMultiplesOf10OfSet = await koconutSet
      .find(eachNumber => eachNumber % 10 == 0)
      .yield()
      console.log(foundMultiplesOf10OfSet)
      // ↑ null @@ -629,7 +629,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    findLast

    Returns KoconutPrimitive<null | DataType>

    findLast

    • Returns the last element matching the given predicate, or null if no such element was found.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const lastEventNumberOfArray = await koconutArray
      .findLast(eachNumber => eachNumber % 2 == 0)
      .yield()
      console.log(lastEventNumberOfArray)
      // ↑ 4

      const lastMultiplesOf10Array = await koconutArray
      .findLast(eachNumber => eachNumber % 10 == 0)
      .yield()
      console.log(lastMultiplesOf10Array)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const lastOddNumberOfSet = await koconutSet
      .findLast(eachNumber => eachNumber % 2 == 1)
      .yield()
      console.log(lastOddNumberOfSet)
      // ↑ 5

      const lastMultiplesOf10OfSet = await koconutSet
      .findLast(eachNumber => eachNumber % 10 == 0)
      .yield()
      console.log(lastMultiplesOf10OfSet)
      // ↑ null @@ -638,7 +638,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    first

    Returns KoconutPrimitive<null | DataType>

    first

    • Returns the first element matching the given predicate. Or, if predicate is omitted method will just return the very first element of this collection. If source data is null or no element matching given predicate is found, it throws KoconutNoSuchElementException.

      @@ -651,7 +651,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<DataType>

    firstOrNull

    Returns KoconutPrimitive<DataType>

    firstOrNull

    • Returns the first element matching the given predicate. Or, if predicate is omitted method will just return the very first element of this collection. If source data is null or no element matching given predicate is found, it returns null.

      @@ -662,14 +662,14 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    indexOf

    Returns KoconutPrimitive<null | DataType>

    indexOf

    • Returns first index of element. or -1 if the collection does not contains element.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const indexOf3 = await koconutArray
      .indexOf(3)
      .yield()
      console.log(indexOf3)
      // ↑ 2

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const indexOf10 = await koconutSet
      .indexOf(10)
      .yield()
      console.log(indexOf10)
      // ↑ -1

      Parameters

      • elementToFind: DataType

        The element to search for.

        -

      Returns KoconutPrimitive<number>

    indexOfFirst

    Returns KoconutPrimitive<number>

    indexOfFirst

    • Returns index of the first element matching the given predicate, or -1 if the collection does not contain such element.

      since

      1.0.10

      @@ -679,7 +679,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<number>

    indexOfLast

    Returns KoconutPrimitive<number>

    indexOfLast

    • Returns index of the last element matching the given predicate, or -1 if the collection does not contain such element.

      since

      1.0.10

      @@ -689,7 +689,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<number>

    Transformer Methods

    associate

    Returns KoconutPrimitive<number>

    Transformer Methods

    associate

    • Returns a KoconutMap containing key-value paired Entry provided by transform function applied to elements of the given collection.

      since

      1.0.10

      @@ -699,7 +699,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    associateBy

    • associateBy<KeyType, ValueType>(keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutMap<KeyType, ValueType>

    Returns KoconutMap<KeyType, ValueType>

    associateBy

    • associateBy<KeyType, ValueType>(keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutMap<KeyType, ValueType>
    • Returns a KoconutMap containing the elements from the given collection indexed by the key returned from keySelector function applied to each element. valueTransform callback function is optional. If it's not omitted the method returns @@ -716,7 +716,7 @@

      An object to which the this keyword can refer in the keySelector. If keySelectorThisArg is omitted, null is used as the this value.

    • valueTransformThisArg: any = null

      An object to which the this keyword can refer in the valueTransform. If valueTransformThisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    associateByTo

    • associateByTo<KeyType, ValueType>(destination: Map<KeyType, ValueType>, keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutArray<DataType>

    Returns KoconutMap<KeyType, ValueType>

    associateByTo

    • associateByTo<KeyType, ValueType>(destination: Map<KeyType, ValueType>, keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutArray<DataType>
    • Populates the given destination map with entries, where key is provided by keySelector function applied to each element. valueTransform callback function is optional. If it's omitted, each value of entry @@ -736,7 +736,7 @@

      An object to which the this keyword can refer in the keySelector. If keySelectorThisArg is omitted, null is used as the this value.

    • valueTransformThisArg: any = null

      An object to which the this keyword can refer in the valueTransform. If valueTransformThisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    associateTo

    • associateTo<KeyType, ValueType>(destination: Map<KeyType, ValueType>, transform: Transformer<DataType, [KeyType, ValueType] | Pair<KeyType, ValueType> | KoconutPair<KeyType, ValueType> | Entry<KeyType, ValueType> | KoconutEntry<KeyType, ValueType>>, thisArg?: any): KoconutArray<DataType>

    Returns KoconutArray<DataType>

    associateTo

    • associateTo<KeyType, ValueType>(destination: Map<KeyType, ValueType>, transform: Transformer<DataType, [KeyType, ValueType] | Pair<KeyType, ValueType> | KoconutPair<KeyType, ValueType> | Entry<KeyType, ValueType> | KoconutEntry<KeyType, ValueType>>, thisArg?: any): KoconutArray<DataType>
    • Populates the given destination map with entries, provided by transform function applied to elements of the given collection

      note

      This method has different functionality with Kotlin. It'll return the original collection instance.

      @@ -749,7 +749,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    associateWith

    • associateWith<ValueType>(valueSelector: Selector<DataType, ValueType>, thisArg?: any): KoconutMap<DataType, ValueType>

    Returns KoconutArray<DataType>

    associateWith

    • associateWith<ValueType>(valueSelector: Selector<DataType, ValueType>, thisArg?: any): KoconutMap<DataType, ValueType>
    • Returns a KoconutMap where keys are original elements of the current object and values are produced by the valueSelector function applied to each element.

      since

      1.0.10

      @@ -759,7 +759,7 @@

      A callback function that accepts an argument. The method calls the valueSelector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the valueSelector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<DataType, ValueType>

    associateWithTo

    • associateWithTo<ValueType>(destination: Map<DataType, ValueType>, valueSelector: Selector<DataType, ValueType>, thisArg?: any): KoconutArray<DataType>

    Returns KoconutMap<DataType, ValueType>

    associateWithTo

    • associateWithTo<ValueType>(destination: Map<DataType, ValueType>, valueSelector: Selector<DataType, ValueType>, thisArg?: any): KoconutArray<DataType>
    • Populates the given destination map with entries for each element of the given collection, where key is the element itslef and value is provided by valueSelector function applied to that key.

      @@ -773,7 +773,7 @@

      A callback function that accepts an argument. The method calls the valueSelector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the valueSelector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    chunked

    • chunked<ResultDataType>(size: number, transform: null | Transformer<DataType[], ResultDataType>, thisArg: any): KoconutArray<DataType[] | ResultDataType>

    Returns KoconutArray<DataType>

    chunked

    • chunked<ResultDataType>(size: number, transform: null | Transformer<DataType[], ResultDataType>, thisArg: any): KoconutArray<DataType[] | ResultDataType>

    Returns KoconutArray<DataType[] | ResultDataType>

    flatMap

    • flatMap<ResultDataType>(transform: Transformer<DataType, Iterable<ResultDataType>>, thisArg?: any): KoconutArray<ResultDataType>

    Returns KoconutArray<DataType[] | ResultDataType>

    flatMap

    • flatMap<ResultDataType>(transform: Transformer<DataType, Iterable<ResultDataType>>, thisArg?: any): KoconutArray<ResultDataType>
    • Returns a single list of all elements yielded from results of transform function being invoked on each element of original collection.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of("123", "45")

      const allNumberInArray = await koconutArray
      .flatMap(eachString => eachString)
      // ↑ The string itself can be used as Iterable<string>.
      // If you want to make it clear, also possible to type
      // as eachString => eachString.split('')
      .map(parseInt)
      .yield()
      console.log(allNumberInArray)
      // ↑ [ 1, 2, 3, 4, 5 ]

      // Case 2 - KoconutSet
      const koconutSet = KoconutSet.of("abc", "de")

      const allCharactersInSet = await koconutSet
      .flatMap(eachString => eachString)
      .yield()
      console.log(allCharactersInSet)
      // ↑ [ 'a', 'b', 'c', 'd', 'e' ]

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associateWith(eachNumber => eachNumber * 2)

      const allKeysAndValuesInMap = await koconutMap
      .flatMap(eachEntry => [eachEntry.key, eachEntry.value])
      .yield()
      console.log(allKeysAndValuesInMap)
      // ↑ [1, 2, 2, 4, 3, 6, 4, 8, 5, 10]


      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(123, 987)

      const allDigitsInArray = await koconutArray2
      .flatMap(async eachNumber => {
      const digits = new Array<number>()
      while(eachNumber != 0) {
      digits.unshift(eachNumber % 10)
      eachNumber = Math.floor(eachNumber / 10)
      }
      return digits
      })
      .yield()
      console.log(allDigitsInArray)
      // ↑ [ 1, 2, 3, 9, 8, 7 ]

      const allNumberCharactersInArray = await koconutArray2
      .flatMap(eachNumber => new Promise<string>(resolve => {
      resolve(eachNumber.toString())
      }))
      .yield()
      console.log(allNumberCharactersInArray)
      // ↑ [ '1', '2', '3', '9', '8', '7' ] @@ -796,7 +796,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    flatMapIndexed

    Returns KoconutArray<ResultDataType>

    flatMapIndexed

    • Returns a KoconutArray of all elements yielded from results of transform function being invoked on each element of original collection.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(100, 101, 102)

      const allNumbersAndIndexOfArray = await koconutArray
      .flatMapIndexed((eachIndex, eachNumber) =>
      [eachIndex, eachNumber]
      )
      .yield()
      console.log(allNumbersAndIndexOfArray)
      // ↑ [ 0, 100, 1, 101, 2, 102 ]

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(100, 101, 102)

      const allNumbersAndIndexOfSet = await koconutSet
      .flatMapIndexed((eachIndex, eachNumber) =>
      [eachIndex, eachNumber]
      )
      .yield()
      console.log(allNumbersAndIndexOfSet)
      // ↑ [ 0, 100, 1, 101, 2, 102 ]

      // Case 3 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(123, 987)

      const allDigitsAndIndexInArray = await koconutArray2
      .flatMapIndexed(async (eachIndex, eachNumber) => {
      const digits = new Array<number>()
      while(eachNumber != 0) {
      digits.unshift(eachNumber % 10)
      eachNumber = Math.floor(eachNumber / 10)
      }
      return [eachIndex, ...digits]
      })
      .yield()
      console.log(allDigitsAndIndexInArray)
      // ↑ [
      // 0, 1, 2, 3,
      // 1, 9, 8, 7
      // ]

      const allNumberAndIndexCharactersInArray = await koconutArray2
      .flatMapIndexed((eachInex, eachNumber) => new Promise<string>(resolve => {
      resolve(`${eachInex}${eachNumber}`)
      }))
      .yield()
      console.log(allNumberAndIndexCharactersInArray)
      // ↑ [
      // '0', '1', '2',
      // '3', '1', '9',
      // '8', '7'
      // ] @@ -805,7 +805,7 @@

      A callback function that accepts two arguments. The method calls the transform one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    flatMapIndexedTo

    • flatMapIndexedTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, Iterable<ResultDataType>>, thisArg?: any): KoconutArray<DataType>

    Returns KoconutArray<ResultDataType>

    flatMapIndexedTo

    • flatMapIndexedTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, Iterable<ResultDataType>>, thisArg?: any): KoconutArray<DataType>
    • Appends all elements yielded from results of transform function being invoked on each element and its index in the original collection, to the given destination.

      since

      1.0.10

      @@ -817,7 +817,7 @@

      A callback function that accepts two arguments. The method calls the transform one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    flatMapTo

    • flatMapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, Iterable<ResultDataType>>, thisArg?: any): KoconutArray<DataType>

    Returns KoconutArray<DataType>

    flatMapTo

    • flatMapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, Iterable<ResultDataType>>, thisArg?: any): KoconutArray<DataType>
    • Appends all elements yielded from results of transform function being invoked on each element of original collection, to the given destination.

      since

      1.0.10

      @@ -829,7 +829,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    groupBy

    • groupBy<KeyType, ValueType>(keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutMap<KeyType, ValueType[]>

    Returns KoconutArray<DataType>

    groupBy

    • groupBy<KeyType, ValueType>(keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutMap<KeyType, ValueType[]>
    • Groups values returned by the valueTransform function applied to each element of the original collection by the key returned by the given keySelector function applied to the element and returns a map where each group key is associated with a list of corresponding values. If valueTransform is omitted, the value of @@ -845,7 +845,7 @@

      An object to which the this keyword can refer in the keySelector. If keySelectorThisArg is omitted, null is used as the this value.

    • valueTransformThisArg: any = null

      An object to which the this keyword can refer in the valueTransform. If valueTransformThisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType[]>

    groupByTo

    • groupByTo<KeyType, ValueType>(destination: Map<KeyType, ValueType[]>, keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutArray<DataType>

    Returns KoconutMap<KeyType, ValueType[]>

    groupByTo

    • groupByTo<KeyType, ValueType>(destination: Map<KeyType, ValueType[]>, keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutArray<DataType>
    • Groups values returned by the valueTransform function applied to each element of the original collection by the key returned by the given keySelector function applied to the element and puts to the destination map each group key associated with a list of corresponding values. If valueTransform is omitted, each value would be original element.

      @@ -862,7 +862,7 @@

      An object to which the this keyword can refer in the keySelector. If keySelectorThisArg is omitted, null is used as the this value.

    • valueTransformThisArg: any = null

      An object to which the this keyword can refer in the valueTransform. If valueTransformThisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    map

    Returns KoconutArray<DataType>

    map

    • Returns a list containing the results of applying the given transform function to each element in the original collection.

      since

      1.0.10

      @@ -872,7 +872,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    mapIndexed

    Returns KoconutArray<ResultDataType>

    mapIndexed

    • Returns a list of all elements yielded from results of transform function being invoked on each element and its index in the original collection.

      since

      1.0.10

      @@ -882,7 +882,7 @@

      A callback function that accepts two arguments. The method calls the transform one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    mapIndexedNotNull

    • mapIndexedNotNull<ResultDataType>(transform: IndexedTransformer<DataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    Returns KoconutArray<ResultDataType>

    mapIndexedNotNull

    • mapIndexedNotNull<ResultDataType>(transform: IndexedTransformer<DataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>
    • Returns a KoconutArray containing only the results that are not null nor undefined of applying the given transform function to each element and its index in the original collection.

      since

      1.0.10

      @@ -892,7 +892,7 @@

      A callback function that accepts two arguments. The method calls the transform one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    mapIndexedNotNullTo

    • mapIndexedNotNullTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<DataType>

    Returns KoconutArray<ResultDataType>

    mapIndexedNotNullTo

    • mapIndexedNotNullTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<DataType>
    • Applies the given transform function to each element and its index in the original collection and appends the results that are not null nor undefined to the given destination.

      since

      1.0.10

      @@ -904,7 +904,7 @@

      A callback function that accepts two arguments. The method calls the transform one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    mapIndexedTo

    • mapIndexedTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, ResultDataType>, thisArg?: any): KoconutArray<DataType>

    Returns KoconutArray<DataType>

    mapIndexedTo

    • mapIndexedTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, ResultDataType>, thisArg?: any): KoconutArray<DataType>
    • Applies the given transform function to each element and its index in the original collection and appends the results to the given destination.

      since

      1.0.10

      @@ -916,7 +916,7 @@

      A callback function that accepts two arguments. The method calls the transform one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    mapNotNull

    • mapNotNull<ResultDataType>(transform: Transformer<DataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    Returns KoconutArray<DataType>

    mapNotNull

    • mapNotNull<ResultDataType>(transform: Transformer<DataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>
    • Returns a list containing results that are not null nor undefined of applying the given transfrom function to each element in the original collection. You can use this method as filter then map.

      since

      1.0.10

      @@ -926,7 +926,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    mapNotNullTo

    • mapNotNullTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, ResultDataType>, thisArg?: any): KoconutArray<DataType>

    Returns KoconutArray<ResultDataType>

    mapNotNullTo

    • mapNotNullTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, ResultDataType>, thisArg?: any): KoconutArray<DataType>
    • Applies the given transform function to each element of the original collection and appends only the results that are not null nor undefined.

      since

      1.0.10

      @@ -938,7 +938,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<DataType>

    mapTo

    • mapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, ResultDataType>, thisArg?: any): KoconutArray<DataType>

    Returns KoconutArray<DataType>

    mapTo

    • mapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, ResultDataType>, thisArg?: any): KoconutArray<DataType>

    let

    • let<ReturnType>(block: Selector<boolean, 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.

      @@ -29,17 +29,17 @@

      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>

    process

    • process(): Promise<void>

    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

    retrieve

    yield

    • yield(): Promise<boolean>

    yield

    • yield(): Promise<boolean>

    Hierarchy

    Implements

    Index

    Constructors

    Methods Other

    Methods Processor

    Constructors

    constructor

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

    Hierarchy

    Implements

    Index

    Constructors

    Methods Other

    Methods Processor

    Constructors

    constructor

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

    Other Methods

    equalsTo

    Returns KoconutEntry<KeyType, ValueType>

    Other Methods

    equalsTo

    Processor Methods

    also

    Returns boolean | KoconutBoolean

    Processor Methods

    also

    • 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

      @@ -33,7 +33,7 @@

      Parameters

      • block: Processor<Entry<KeyType, ValueType>>

        A callback function that accepts an argument.

        -

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

    let

    • let<ReturnType>(block: Selector<Entry<KeyType, ValueType>, ReturnType>): Promise<ReturnType>

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

    let

    • let<ReturnType>(block: Selector<Entry<KeyType, ValueType>, 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.

      @@ -42,17 +42,17 @@

      Type parameters

      • ReturnType

      Parameters

      • block: Selector<Entry<KeyType, ValueType>, ReturnType>

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

        -

      Returns Promise<ReturnType>

    process

    • process(): Promise<void>

    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

    retrieve

    yield

    • yield(): Promise<Entry<KeyType, ValueType>>

    yield

    • yield(): Promise<Entry<KeyType, ValueType>>

    Accessors

    entries

    Returns KoconutMap<KeyType, ValueType>

    Accessors

    entries

    • Returns a KoconutSet contains every Entry.

      since

      1.0.10

      example
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associateWith(eachNumber => eachNumber * 2)

      const entries = await koconutMap
      .entries
      .yield()
      console.log(entries)
      // ↑ Set {
      // Entry { keyElement: 1, valueElement: 2 },
      // Entry { keyElement: 2, valueElement: 4 },
      // Entry { keyElement: 3, valueElement: 6 },
      // Entry { keyElement: 4, valueElement: 8 },
      // Entry { keyElement: 5, valueElement: 10 }
      // }
      -

      Returns KoconutSet<Entry<KeyType, ValueType>>

    keys

    keys

    • Returns a KoconutSet contains all keys.

      since

      1.0.10

      example
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associateWith(eachNumber => eachNumber * 2)

      const keys = await koconutMap
      .keys
      .yield()
      console.log(keys)
      // ↑ Set { 1, 2, 3, 4, 5 }
      -

      Returns KoconutSet<KeyType>

    size

    size

    values

    values

    Calculator Methods

    count

    Calculator Methods

    count

    • Returns the number of the elements matching the given predicate. If the predicate is ommitted it'll returns the whole number of elements.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const numberOfAllArrayElements = await koconutArray
      .count()
      .yield()
      console.log(numberOfAllArrayElements)
      // ↑ 5

      const numberOfArrayElementsHigherThan2 = await koconutArray
      .count(eachNumber => eachNumber > 2)
      .yield()
      console.log(numberOfArrayElementsHigherThan2)
      // ↑ 3 -- i.e. [3, 4, 5]

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const numberOfAllSetElements = await koconutSet
      .count()
      .yield()
      console.log(numberOfAllSetElements)
      // ↑ 5

      const numberOfOddSetElements = await koconutSet
      .count(eachNumber => eachNumber % 2 == 1)
      .yield()
      console.log(numberOfOddSetElements)
      // ↑ 3 -- i.e. [1, 3, 5]

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3)
      .associateWith(eachNumber => eachNumber * 2)
      // ↑ Map { 1 => 2,
      // 2 => 4,
      // 3 => 6 }

      const numberOfAllMapEntries = await koconutMap
      .count()
      .yield()
      console.log(numberOfAllMapEntries)
      // ↑ 3

      const numberOfMapEntriesValueHigherThan5 = await koconutMap
      .count(eachEntry => eachEntry.value > 5)
      .yield()
      console.log(numberOfMapEntriesValueHigherThan5)
      // ↑ 1 -- i.e. Entry { 3, 6 }

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(1,2,3,4,5)

      const numberOfArrayElementsLessThan3 = await koconutArray2
      .count(async eachNumber => eachNumber < 3)
      .yield()
      console.log(numberOfArrayElementsLessThan3)
      // ↑ 2 -- i.e. [1, 2]

      const numberOfEvenArrayElements = await koconutArray2
      .count(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 2 == 0)
      }))
      .yield()
      console.log(numberOfEvenArrayElements)
      // ↑ 2 -- i.e. [2, 4] @@ -35,7 +35,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<number>

    maxBy

    Returns KoconutPrimitive<number>

    maxBy

    Returns KoconutEntry<KeyType, ValueType>

    maxByOrNull

    Returns KoconutEntry<KeyType, ValueType>

    maxByOrNull

    • Returns the first entry yielding the largest value of the given function or null if there are no entries.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const largestNumberOfArray = await koconutArray
      .maxByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(largestNumberOfArray)
      // ↑ 5


      const largestNumberOfEmptyArray = await koconutArray
      .filter(eachNumber => eachNumber > 10)
      .maxByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(largestNumberOfEmptyArray)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of("a", "ab", "abc")

      const longestStringOfSet = await koconutSet
      .maxByOrNull(eachString => eachString.length)
      .yield()
      console.log(longestStringOfSet)
      // ↑ abc

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1, 12, 123)
      .associateWith(eachNumber => eachNumber.toString())

      const longestDigitsEntryOfMap = await koconutMap
      .maxByOrNull(eachEntry => eachEntry.value.length)
      .yield()
      console.log(longestDigitsEntryOfMap)
      // ↑ Entry { keyElement: 123, valueElement: '123' }

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(19,27,32)

      const largestNumberOfArray2 = await koconutArray2
      .maxByOrNull(async eachNumber => eachNumber)
      .yield()
      console.log(largestNumberOfArray2)
      // ↑ 32

      const largest1sDigitNumberOfArray2 = await koconutArray2
      .maxByOrNull(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 10)
      }))
      .yield()
      console.log(largest1sDigitNumberOfArray2)
      // ↑ 19 @@ -56,7 +56,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each entry in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutEntry<KeyType, ValueType>

    maxOf

    • maxOf<ComparableType>(selector: Selector<Entry<KeyType, ValueType>, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutEntry<KeyType, ValueType>

    maxOf

    • maxOf<ComparableType>(selector: Selector<Entry<KeyType, ValueType>, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    maxOfOrNull

    • maxOfOrNull<ComparableType>(selector: Selector<Entry<KeyType, ValueType>, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    maxOfOrNull

    • maxOfOrNull<ComparableType>(selector: Selector<Entry<KeyType, ValueType>, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>
    • Returns the largest value among all values produced by selector function applied to each element in the collection or null if there are no elements.

      since

      1.0.10

      @@ -77,7 +77,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | string | number | ComparableType>

    maxOfWith

    • maxOfWith<ResultDataType>(selector: Selector<Entry<KeyType, ValueType>, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>

    Returns KoconutPrimitive<null | string | number | ComparableType>

    maxOfWith

    • maxOfWith<ResultDataType>(selector: Selector<Entry<KeyType, ValueType>, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>
    • Returns the largest value according to the provided comparator among all values produced by selector function applied to each element in the collection all throws KoconutNoSuchElementException if elements are empty.

      @@ -94,7 +94,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<ResultDataType>

    maxOfWithOrNull

    • maxOfWithOrNull<ResultDataType>(selector: Selector<Entry<KeyType, ValueType>, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>

    Returns KoconutPrimitive<ResultDataType>

    maxOfWithOrNull

    • maxOfWithOrNull<ResultDataType>(selector: Selector<Entry<KeyType, ValueType>, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>
    • Returns the largest value according to the provided comparator among all values produced by selector function applied to each element in the collection or null if elements are empty.

      @@ -110,7 +110,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | ResultDataType>

    maxWith

    Returns KoconutPrimitive<null | ResultDataType>

    maxWith

    Returns KoconutEntry<KeyType, ValueType>

    maxWithOrNull

    Returns KoconutEntry<KeyType, ValueType>

    maxWithOrNull

    • Returns the first element having the largest value according to the provided comparator or null if elements are empty.

      since

      1.0.10

      @@ -133,7 +133,7 @@ In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.

    • thisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutEntry<KeyType, ValueType>

    minBy

    Returns KoconutEntry<KeyType, ValueType>

    minBy

    Returns KoconutEntry<KeyType, ValueType>

    minByOrNull

    Returns KoconutEntry<KeyType, ValueType>

    minByOrNull

    • Returns the first entry yielding the smallest value of the given function or null if there are no entries.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const smallestNumberOfArray = await koconutArray
      .minByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(smallestNumberOfArray)
      // ↑ 1

      const smallestNumberOfEmptyArray = await koconutArray
      .filter(eachNumber => eachNumber > 10)
      .minByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(smallestNumberOfEmptyArray)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of("a", "ab", "abc")

      const shortestStringOfSet = await koconutSet
      .minByOrNull(eachString => eachString.length)
      .yield()
      console.log(shortestStringOfSet)
      // ↑ a

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1, 12, 123)
      .associateWith(eachNumber => eachNumber.toString())

      const shortestDigitsEntryOfMap = await koconutMap
      .minByOrNull(eachEntry => eachEntry.value.length)
      .yield()
      console.log(shortestDigitsEntryOfMap)
      // ↑ Entry { keyElement: 1, valueElement: '1' }

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(19,27,32)

      const smallestNumberOfArray2 = await koconutArray2
      .minByOrNull(async eachNumber => eachNumber)
      .yield()
      console.log(smallestNumberOfArray2)
      // ↑ 19

      const smallest1sDigitNumberOfArray2 = await koconutArray2
      .minByOrNull(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 10)
      }))
      .yield()
      console.log(smallest1sDigitNumberOfArray2)
      // ↑ 32 @@ -154,7 +154,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each entry in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutEntry<KeyType, ValueType>

    minOf

    • minOf<ComparableType>(selector: Selector<Entry<KeyType, ValueType>, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutEntry<KeyType, ValueType>

    minOf

    • minOf<ComparableType>(selector: Selector<Entry<KeyType, ValueType>, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    minOfOrNull

    • minOfOrNull<ComparableType>(selector: Selector<Entry<KeyType, ValueType>, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    minOfOrNull

    • minOfOrNull<ComparableType>(selector: Selector<Entry<KeyType, ValueType>, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>
    • Returns the smallest value among all values produced by selector function applied to each element in the collection or null if there are no elements.

      since

      1.0.10

      @@ -175,7 +175,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | string | number | ComparableType>

    minOfWith

    • minOfWith<ResultDataType>(selector: Selector<Entry<KeyType, ValueType>, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>

    Returns KoconutPrimitive<null | string | number | ComparableType>

    minOfWith

    • minOfWith<ResultDataType>(selector: Selector<Entry<KeyType, ValueType>, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>
    • Returns the smallest value according to the provided comparator among all values produced by selector function applied to each element in the collection all throws KoconutNoSuchElementException if elements are empty.

      @@ -192,7 +192,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<ResultDataType>

    minOfWithOrNull

    • minOfWithOrNull<ResultDataType>(selector: Selector<Entry<KeyType, ValueType>, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>

    Returns KoconutPrimitive<ResultDataType>

    minOfWithOrNull

    • minOfWithOrNull<ResultDataType>(selector: Selector<Entry<KeyType, ValueType>, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>
    • Returns the smallest value according to the provided comparator among all values produced by selector function applied to each element in the collection all null if elements are empty.

      @@ -209,7 +209,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | ResultDataType>

    minWith

    Returns KoconutPrimitive<null | ResultDataType>

    minWith

    Returns KoconutEntry<KeyType, ValueType>

    minWithOrNull

    Returns KoconutEntry<KeyType, ValueType>

    minWithOrNull

    • Returns the first element having the smallest value according to the provided comparator or null if elements are empty.

      since

      1.0.10

      @@ -232,17 +232,17 @@ In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.

    • thisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutEntry<KeyType, ValueType>

    Caster Methods

    asArray

    Returns KoconutEntry<KeyType, ValueType>

    Caster Methods

    asArray

    • Creates an KoconutArray instance that wraps original data.

      since

      1.0.13

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const arrToArr = await koconutArray
      .asArray()
      .yield()
      console.log(arrToArr)
      // ↑ [ 1, 2, 3, 4, 5 ]

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,1,2,2,3,3,4,4,5,5)

      const setToArr = await koconutSet
      .asArray()
      .yield()
      console.log(setToArr)
      // ↑ [ 1, 2, 3, 4, 5 ]

      // Case 3 -- KoconutFlow
      const koconutFlow = KoconutFlow.ofSimple(1,2,3,4,5)

      const flowToArr = await koconutFlow
      .asArray()
      .yield()
      console.log(flowToArr)
      // ↑
      // [
      // Entry { keyElement: 0, valueElement: 1 },
      // Entry { keyElement: 1, valueElement: 2 },
      // Entry { keyElement: 2, valueElement: 3 },
      // Entry { keyElement: 3, valueElement: 4 },
      // Entry { keyElement: 4, valueElement: 5 }
      // ]

      // Case 4 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber])

      const mapToArr = await koconutMap
      .asArray()
      .yield()
      console.log(mapToArr)
      // ↑
      // [
      // Entry { keyElement: 1, valueElement: 1 },
      // Entry { keyElement: 2, valueElement: 2 },
      // Entry { keyElement: 3, valueElement: 3 },
      // Entry { keyElement: 4, valueElement: 4 },
      // Entry { keyElement: 5, valueElement: 5 }
      // ]
      -

      Returns KoconutArray<Entry<KeyType, ValueType>>

    asSet

    asSet

    • Creates an KoconutSet instance that wraps original data.

      since

      1.0.13

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const arrToSet = await koconutArray
      .asSet()
      .yield()
      console.log(arrToSet)
      // ↑ Set { 1, 2, 3, 4, 5 }

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,1,2,2,3,3,4,4,5,5)

      const setToSet = await koconutSet
      .asSet()
      .yield()
      console.log(setToSet)
      // ↑ Set { 1, 2, 3, 4, 5 }

      // Case 3 -- KoconutFlow
      const koconutFlow = KoconutFlow.ofSimple(1,2,3,4,5)

      const flowToSet = await koconutFlow
      .asSet()
      .yield()
      console.log(flowToSet)
      // ↑
      // Set {
      // Entry { keyElement: 0, valueElement: 1 },
      // Entry { keyElement: 1, valueElement: 2 },
      // Entry { keyElement: 2, valueElement: 3 },
      // Entry { keyElement: 3, valueElement: 4 },
      // Entry { keyElement: 4, valueElement: 5 }
      // }

      // Case 4 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber])

      const mapToSet = await koconutMap
      .asSet()
      .yield()
      console.log(mapToSet)
      // ↑
      // Set {
      // Entry { keyElement: 1, valueElement: 1 },
      // Entry { keyElement: 2, valueElement: 2 },
      // Entry { keyElement: 3, valueElement: 3 },
      // Entry { keyElement: 4, valueElement: 4 },
      // Entry { keyElement: 5, valueElement: 5 }
      // }
      -

      Returns KoconutSet<Entry<KeyType, ValueType>>

    Creator Methods

    Static from

    • from<KeyType, ValueType>(source?: null | Iterable<[KeyType, ValueType] | Entry<KeyType, ValueType> | Pair<KeyType, ValueType>>): KoconutMap<KeyType, ValueType>

    Creator Methods

    Static from

    • from<KeyType, ValueType>(source?: null | Iterable<[KeyType, ValueType] | Entry<KeyType, ValueType> | Pair<KeyType, ValueType>>): KoconutMap<KeyType, ValueType>
    • Creates a new instance from iterable object. Inner data type could be an Array of two values([Key, Value]), a Pair or an Entry.

      since

      1.0.11

      @@ -250,7 +250,7 @@

      Type parameters

      • KeyType

      • ValueType

      Parameters

      • source: null | Iterable<[KeyType, ValueType] | Entry<KeyType, ValueType> | Pair<KeyType, ValueType>> = null

        An map-like iterable object to convert to a KoconutMap.

        -

      Returns KoconutMap<KeyType, ValueType>

    Static generate

    • generate<KeyType, ValueType>(count: number, generator: Generator<[KeyType, ValueType] | Pair<KeyType, ValueType> | KoconutPair<KeyType, ValueType> | Entry<KeyType, ValueType> | KoconutEntry<KeyType, ValueType>>, thisArg?: any): KoconutMap<KeyType, ValueType>

    Returns KoconutMap<KeyType, ValueType>

    Static generate

    • generate<KeyType, ValueType>(count: number, generator: Generator<[KeyType, ValueType] | Pair<KeyType, ValueType> | KoconutPair<KeyType, ValueType> | Entry<KeyType, ValueType> | KoconutEntry<KeyType, ValueType>>, thisArg?: any): KoconutMap<KeyType, ValueType>
    • Creates a new instance with given count as number of entries. count cannot be negative number. Each entry is provided from generator with given ordered index.

      throws

      KoconutInvalidArgumentException @@ -264,7 +264,7 @@

      A callback function that accepts an argument. The method calls the action one time for each ordered index.

    • thisArg: any = null

      An object to which the this keyword can refer in the generator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    Static of

    • of<KeyType, ValueType>(...data: ([KeyType, ValueType] | Entry<KeyType, ValueType> | Pair<KeyType, ValueType>)[]): KoconutMap<KeyType, ValueType>

    Returns KoconutMap<KeyType, ValueType>

    Static of

    • of<KeyType, ValueType>(...data: ([KeyType, ValueType] | Entry<KeyType, ValueType> | Pair<KeyType, ValueType>)[]): KoconutMap<KeyType, ValueType>
    • Creates a new instance from variable number of arguments. Inner data type could be an Array of two values([Key, Value]), a Pair or an Entry.

      since

      1.0.11

      @@ -272,7 +272,7 @@

      Type parameters

      • KeyType

      • ValueType

      Parameters

      • Rest ...data: ([KeyType, ValueType] | Entry<KeyType, ValueType> | Pair<KeyType, ValueType>)[]

        A set of elements to include in the new KoconutMap object.

        -

      Returns KoconutMap<KeyType, ValueType>

    Inspector Methods

    all

    Returns KoconutMap<KeyType, ValueType>

    Inspector Methods

    all

    • Return true if all elements match te given predicate.

      since

      1.0.10

      example
        // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const areAllArrayElementsGreaterThan0 = await koconutArray
      .all(eachNumber => eachNumber > 0)
      .yield()
      console.log(areAllArrayElementsGreaterThan0)
      // ↑ true

      const areAllArrayElementsEven = await koconutArray
      .all(eachNumber => eachNumber % 2 == 0)
      .yield()
      console.log(areAllArrayElementsEven)
      // ↑ false -- i.e. '1' is not an even number.


      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const areAllSetElementsGreaterThan0 = await koconutSet
      .all(eachNumber => eachNumber > 0)
      .yield()
      console.log(areAllSetElementsGreaterThan0)
      // ↑ true

      const areAllSetElementsOdd = await koconutSet
      .all(eachNumber => eachNumber % 2 == 1)
      .yield()
      console.log(areAllSetElementsOdd)
      // ↑ false -- i.e. '2' is not an odd number.


      // Case 3 -- KoconutMap
      const koconutMap = KoconutMap.of(
      [0, 0],
      [1, 1],
      [2, 2]
      )

      const areAllMapEntriesKeyEqualsToValue = await koconutMap
      .all(eachEntry => eachEntry.key == eachEntry.value)
      .yield()
      console.log(areAllMapEntriesKeyEqualsToValue)
      // ↑ true

      const areAllMapEntriesSumGreaterThan3 = await koconutMap
      .all(eachEntry => eachEntry.key + eachEntry.value > 3)
      .yield()
      console.log(areAllMapEntriesSumGreaterThan3)
      // ↑ false -- i.e. Sum of key and value of first Entry { 0, 0 } is 0.
      // It's definetly less than 3

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(1,2,3,4,5)

      const areAllArrayElementsLessThan10 = await koconutArray2
      .all(async eachNumber => eachNumber < 10)
      .yield()
      console.log(areAllArrayElementsLessThan10)
      // ↑ true

      const areAllArrayElementsOdd = await koconutArray2
      .all(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 2 == 1)
      }))
      .yield()
      console.log(areAllArrayElementsOdd)
      // ↑ false -- i.e. '2' is not an odd number. @@ -281,7 +281,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutBoolean

    any

    Returns KoconutBoolean

    any

    • Returns true if the collection has at least one element matches the given predicate.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isAnyArrayElementGreaterThan4 = await koconutArray
      .any(eachNumber => eachNumber > 4)
      .yield()
      console.log(isAnyArrayElementGreaterThan4)
      // ↑ true -- i.e. '5' is greater than 4.

      const isAnyArrayElementMultipleOf6 = await koconutArray
      .any(eachNumber => eachNumber % 6 == 0)
      .yield()
      console.log(isAnyArrayElementMultipleOf6)
      // ↑ false

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isAnySetElementGreaterThan3 = await koconutSet
      .any(eachNumber => eachNumber > 3)
      .yield()
      console.log(isAnySetElementGreaterThan3)
      // ↑ true -- i.e. '4' is greater than 3.

      const isAnySetElementLessThan0 = await koconutSet
      .any(eachNumber => eachNumber < 0)
      .yield()
      console.log(isAnySetElementLessThan0)
      // ↑ false

      // Case 3 -- KoconutMap
      const koconutMap = KoconutMap.of(
      [0, 0],
      [1, 1],
      [2, 2]
      )

      const isAnyMapEntrySumGreaterThan3 = await koconutMap
      .any(eachEntry => eachEntry.key + eachEntry.value > 3)
      .yield()
      console.log(isAnyMapEntrySumGreaterThan3)
      // ↑ true -- i.e. Sum of key and value of third Entry { 2, 2 } is 4.
      // It's grater than 4.

      const isAnyMapEntryKeyMultipleOf4 = await koconutMap
      .any(eachEntry => eachEntry.key > 0 && eachEntry.key % 4 == 0)
      .yield()
      console.log(isAnyMapEntryKeyMultipleOf4)
      // ↑ false

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(1,2,3,4,5)

      const isAnyArrayElementLessThan2 = await koconutArray2
      .any(async eachNumber => eachNumber < 2)
      .yield()
      console.log(isAnyArrayElementLessThan2)
      // ↑ true -- i.e. '1' is less than 2.

      const isAnyArrayElementGreaterThan7 = await koconutArray2
      .any(eachNumber => new Promise(resolve => {
      resolve(eachNumber > 7)
      }))
      .yield()
      console.log(isAnyArrayElementGreaterThan7)
      // ↑ false @@ -290,45 +290,45 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutBoolean

    contains

    Returns KoconutBoolean

    contains

    • Checks if this KoconutMap contains the given key.

      since

      1.0.10

      example
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber * 2])

      const doesKoconutMapContainsKey4 = await koconutMap
      .contains(4)
      .yield()
      console.log(doesKoconutMapContainsKey4)
      // ↑ true

      const doesKoconutMapContainsKey7 = await koconutMap
      .contains(7)
      .yield()
      console.log(doesKoconutMapContainsKey7)
      // ↑ false

      Parameters

      • key: KeyType

        Key to search for.

        -

      Returns KoconutBoolean

    containsKey

    Returns KoconutBoolean

    containsKey

    • Checks if this KoconutMap contains the given key.

      since

      1.0.10

      example
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber * 2])

      const doesKoconutMapContainsKey4 = await koconutMap
      .containsKey(4)
      .yield()
      console.log(doesKoconutMapContainsKey4)
      // ↑ true

      const doesKoconutMapContainsKey7 = await koconutMap
      .containsKey(7)
      .yield()
      console.log(doesKoconutMapContainsKey7)
      // ↑ false

      Parameters

      • key: KeyType

        Key to search for.

        -

      Returns KoconutBoolean

    containsValue

    Returns KoconutBoolean

    containsValue

    • Checks if this KoconutMap contains given value.

      since

      1.0.10

      example
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber * 2])

      const doesKoconutMapContainsValue2 = await koconutMap
      .containsValue(2)
      .yield()
      console.log(doesKoconutMapContainsValue2)
      // ↑ true

      const doesKoconutMapContainsValue12 = await koconutMap
      .containsValue(12)
      .yield()
      console.log(doesKoconutMapContainsValue12)
      // ↑ false

      Parameters

      • value: ValueType

        Value to search for.

        -

      Returns KoconutBoolean

    isEmpty

    Returns KoconutBoolean

    isEmpty

    • Returns true if the collection is empty (contains no elements), false otherwise.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isNumberArrayEmpty = await koconutArray
      .isEmpty()
      .yield()
      console.log(isNumberArrayEmpty)
      // ↑ false

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isFilteredNumberSetEmpty = await koconutSet
      .filter(eachNumber => eachNumber > 10)
      .isEmpty()
      .yield()
      console.log(isFilteredNumberSetEmpty)
      // ↑ true

      // Case 3 -- KoconutMap
      const koconutMap = new KoconutMap<number, number>()

      const isNumberPairedMapEmpty = await koconutMap
      .isEmpty()
      .yield()
      console.log(isNumberPairedMapEmpty)
      // ↑ true
      -

      Returns KoconutBoolean

    isNotEmpty

    isNotEmpty

    • Returns true if the collection is not empty.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isNumberArrayEmpty = await koconutArray
      .isNotEmpty()
      .yield()
      console.log(isNumberArrayEmpty)
      // ↑ true

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isFilteredNumberSetEmpty = await koconutSet
      .filter(eachNumber => eachNumber > 10)
      .isNotEmpty()
      .yield()
      console.log(isFilteredNumberSetEmpty)
      // ↑ false

      // Case 3 -- KoconutMap
      const koconutMap = new KoconutMap<number, number>()

      const isNumberPairedMapEmpty = await koconutMap
      .isNotEmpty()
      .yield()
      console.log(isNumberPairedMapEmpty)
      // ↑ false
      -

      Returns KoconutBoolean

    isNullOrEmpty

    isNullOrEmpty

    • Returns true if this nullable collection is either null or empty.

      since

      1.0.10

      deprecated

      Use isEmpty instead.

      until

      1.3.0

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isNumberArrayEmpty = await koconutArray
      .isNullOrEmpty()
      .yield()
      console.log(isNumberArrayEmpty)
      // ↑ false

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isFilteredNumberSetEmpty = await koconutSet
      .filter(eachNumber => eachNumber > 10)
      .isNullOrEmpty()
      .yield()
      console.log(isFilteredNumberSetEmpty)
      // ↑ true

      // Case 3 -- KoconutMap
      const koconutMap = new KoconutMap<number, number>()

      const isNumberPairedMapEmpty = await koconutMap
      .isNullOrEmpty()
      .yield()
      console.log(isNumberPairedMapEmpty)
      // ↑ true
      -

      Returns KoconutBoolean

    none

    none

    • predicate callback function is optional. If it's omitted the method returns true if the collection has no elements. Otherwise, returns true if no elements match the given predicate.

      since

      1.0.10

      @@ -338,7 +338,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutBoolean

    Iterator Methods

    forEach

    Returns KoconutBoolean

    Iterator Methods

    forEach

    • Performs the given action on each element. When you want to stop iteration in the meantime return false or KoconutLoopSignal.BREAK.

      since

      1.0.10

      @@ -348,7 +348,7 @@

      A callback function that accepts an argument. The method calls the action one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the action. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<void>

    onEach

    Returns KoconutPrimitive<void>

    onEach

    • Performs the given action on each entry and returns the original collection itself afterwards. When you want to stop iteration in the meantime return false or KoconutLoopSignal.BREAK.

      since

      1.0.10

      @@ -358,7 +358,7 @@

      A callback function that accepts an argument. The method calls the action one time for each entry in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the action. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    Manipulator Methods

    filter

    Returns KoconutMap<KeyType, ValueType>

    Manipulator Methods

    filter

    • Returns a map containing only entries matching the given predicate.

      since

      1.0.10

      example
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber * 2])

      const evenKeyEntries = await koconutMap
      .filter(eachEntry => eachEntry.key % 2 == 0)
      .yield()
      console.log(evenKeyEntries)
      // ↑ Map { 2 => 4, 4 => 8 } @@ -367,7 +367,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each entry in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    filterKeys

    Returns KoconutMap<KeyType, ValueType>

    filterKeys

    • Returns a map containing all entries with key matching the given predicate.

      since

      1.0.10

      example
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber * 2])

      const evenKeyMap = await koconutMap
      .filterKeys(eachKey => eachKey % 2 == 0)
      .yield()
      console.log(evenKeyMap)
      // ↑ Map { 2 => 4, 4 => 8 } @@ -376,7 +376,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each entry in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    filterNot

    Returns KoconutMap<KeyType, ValueType>

    filterNot

    • Returns a map containing only entries not matching the given predicate.

      since

      1.0.10

      example
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber * 2])

      const oddKeyEntries = await koconutMap
      .filterNot(eachEntry => eachEntry.key % 2 == 0)
      .yield()
      console.log(oddKeyEntries)
      // ↑ Map { 1 => 2, 3 => 6, 5 => 10 } @@ -385,7 +385,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each entry in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    filterNotTo

    • filterNotTo(destination: Map<KeyType, ValueType>, predicate: Predicator<Entry<KeyType, ValueType>>, thisArg?: any): KoconutMap<KeyType, ValueType>

    Returns KoconutMap<KeyType, ValueType>

    filterNotTo

    • filterNotTo(destination: Map<KeyType, ValueType>, predicate: Predicator<Entry<KeyType, ValueType>>, thisArg?: any): KoconutMap<KeyType, ValueType>
    • Appends all entries not matching the given predicate to the given destination.

      since

      1.0.10

      example
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber * 2])

      const oddKeyMap = new Map<number, number>()
      const originalMap = await koconutMap
      .filterNotTo(
      oddKeyMap,
      eachEntry => eachEntry.key % 2 == 0
      )
      .yield()
      console.log(oddKeyMap)
      // ↑ Map { 1 => 2, 3 => 6, 5 => 10 }
      console.log(originalMap)
      // ↑ Map { 1 => 2, 2 => 4, 3 => 6, 4 => 8, 5 => 10 } @@ -396,7 +396,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each entry in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    filterTo

    • filterTo(destination: Map<KeyType, ValueType>, predicate: Predicator<Entry<KeyType, ValueType>>, thisArg?: any): KoconutMap<KeyType, ValueType>

    Returns KoconutMap<KeyType, ValueType>

    filterTo

    • filterTo(destination: Map<KeyType, ValueType>, predicate: Predicator<Entry<KeyType, ValueType>>, thisArg?: any): KoconutMap<KeyType, ValueType>
    • Appends all entries matching the given predicate to the given destination.

      since

      1.0.10

      example
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber * 2])

      const evenKeyMap = new Map<number, number>()
      const originalMap = await koconutMap
      .filterTo(
      evenKeyMap,
      eachEntry => eachEntry.key % 2 == 0
      )
      .yield()
      console.log(evenKeyMap)
      // ↑ Map { 2 => 4, 4 => 8 }
      console.log(originalMap)
      // ↑ Map { 1 => 2, 2 => 4, 3 => 6, 4 => 8, 5 => 10 } @@ -407,7 +407,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each entry in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    filterValues

    Returns KoconutMap<KeyType, ValueType>

    filterValues

    • Returns a map containing all entries with value matching the given predicate.

      since

      1.0.10

      example
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber * 2])

      const valueGreaterThan5Map = await koconutMap
      .filterValues(eachValue => eachValue > 5)
      .yield()
      console.log(valueGreaterThan5Map)
      // ↑ Map { 3 => 6, 4 => 8, 5 => 10 } @@ -416,7 +416,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each entry in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    minus

    • minus(...keys: KeyType[]): KoconutMap<KeyType, ValueType>

    Returns KoconutMap<KeyType, ValueType>

    minus

    • minus(...keys: KeyType[]): KoconutMap<KeyType, ValueType>
    • Returns a KoconutMap containing all entries of the original map except the entries the keys of which are contained in keys.

      since

      1.0.10

      @@ -424,14 +424,14 @@

      Parameters

      • Rest ...keys: KeyType[]

        Key data to except. It could be plural or singular.

        -

      Returns KoconutMap<KeyType, ValueType>

    plus

    Returns KoconutMap<KeyType, ValueType>

    plus

    • Returns a KoconutMap by replacing or adding entries from given entries.

      since

      1.0.10

      example
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associateWith(eachNumber => eachNumber * 2)

      const key5ReplacedWith20Map = await koconutMap
      .plus(
      [5, 20]
      // ↑ Also can be
      // new Pair(5, 20)
      // Pair.from([5, 20])
      // new KoconutPair(5, 20)
      // new Entry(5, 20)
      // Entry.from([5, 20])
      // new KoconutEntry(5, 20)
      )
      .yield()
      console.log(key5ReplacedWith20Map)
      // ↑ Map { 1 => 2, 2 => 4, 3 => 6, 4 => 8, 5 => 20 }

      const key6And7AddedMap = await koconutMap
      .plus(
      [6, 12],
      [7, 14]
      )
      .yield()
      console.log(key6And7AddedMap)
      // ↑ Map { 1 => 2, 2 => 4, 3 => 6, 4 => 8, 5 => 10, 6 => 12, 7 => 14 }

      Parameters

      • Rest ...entries: ([KeyType, ValueType] | Entry<KeyType, ValueType> | Pair<KeyType, ValueType> | KoconutEntry<KeyType, ValueType> | KoconutPair<KeyType, ValueType>)[]

        Entries to add or replace. It could be plural or singular.

        -

      Returns KoconutMap<KeyType, ValueType>

    Processor Methods

    also

    • also(block: Processor<Map<KeyType, ValueType>>): Promise<null | Map<KeyType, ValueType>>

    Returns KoconutMap<KeyType, ValueType>

    Processor Methods

    also

    • also(block: Processor<Map<KeyType, ValueType>>): Promise<null | Map<KeyType, ValueType>>
    • 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

      @@ -439,7 +439,7 @@

      Parameters

      • block: Processor<Map<KeyType, ValueType>>

        A callback function that accepts an argument.

        -

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

    let

    • let<ReturnType>(block: Selector<Map<KeyType, ValueType>, ReturnType>): Promise<ReturnType>

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

    let

    • let<ReturnType>(block: Selector<Map<KeyType, ValueType>, 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.

      @@ -448,22 +448,22 @@

      Type parameters

      • ReturnType

      Parameters

      • block: Selector<Map<KeyType, ValueType>, ReturnType>

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

        -

      Returns Promise<ReturnType>

    process

    • process(): Promise<void>

    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

    • retrieve(): Promise<KoconutMap<KeyType, ValueType>>

    retrieve

    • retrieve(): Promise<KoconutMap<KeyType, ValueType>>
    • Processes all the chained object and returns original KoconutMap instance.

      since

      1.0.15

      example
      const koconutMap = await KoconutArray
      .of(1,2,3,4,5)
      .associateWith(eachNumber => eachNumber * 2)
      .retrieve()
      console.log(koconutMap)
      // ↑ KoconutMap {
      // isValidated: true,
      // data: Map { 1 => 2, 2 => 4, 3 => 6, 4 => 8, 5 => 10 },
      // combinedDataWrapper: Set {
      // Entry { keyElement: 1, valueElement: 2 },
      // Entry { keyElement: 2, valueElement: 4 },
      // Entry { keyElement: 3, valueElement: 6 },
      // Entry { keyElement: 4, valueElement: 8 },
      // Entry { keyElement: 5, valueElement: 10 }
      // },
      // mSize: 5,
      // mKeys: Set { 1, 2, 3, 4, 5 },
      // mValues: [ 2, 4, 6, 8, 10 ]
      // }
      -

      Returns Promise<KoconutMap<KeyType, ValueType>>

    yield

    • yield(): Promise<Map<KeyType, ValueType>>

    yield

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

    Selector Methods

    get

    Selector Methods

    get

    getOrDefault

    • getOrDefault(key: KeyType, defaultValue: ValueType): KoconutPrimitive<ValueType>

    Returns KoconutPrimitive<null | ValueType>

    getOrDefault

    • getOrDefault(key: KeyType, defaultValue: ValueType): KoconutPrimitive<ValueType>
    • Returns the value to which the specified key is mapped, or defaultValue if the map contains no mapping for key.

      since

      1.0.10

      @@ -481,7 +481,7 @@

      Key to search for.

    • defaultValue: ValueType

      Default value if no entry is found.

      -

    Returns KoconutPrimitive<ValueType>

    getOrElse

    Returns KoconutPrimitive<ValueType>

    getOrElse

    • Returns the value for the given key, or the reuslt of the defaultValue function if there was no entry from the given key.

      since

      1.0.10

      @@ -493,7 +493,7 @@

      Callback function that generates default value. The method will call defaultValue if no entry is found.

    • thisArg: any = null

      An object to which the this keyword can refer in the defaultValue. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<ValueType>

    getValue

    Returns KoconutPrimitive<ValueType>

    getValue

    Transformer Methods

    flatMap

    • flatMap<ResultDataType>(transform: Transformer<Entry<KeyType, ValueType>, Iterable<ResultDataType>>, thisArg?: any): KoconutArray<ResultDataType>

    Returns KoconutPrimitive<ValueType>

    Transformer Methods

    flatMap

    • flatMap<ResultDataType>(transform: Transformer<Entry<KeyType, ValueType>, Iterable<ResultDataType>>, thisArg?: any): KoconutArray<ResultDataType>
    • Returns a single list of all elements yielded from results of transform function being invoked on each element of original collection.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of("123", "45")

      const allNumberInArray = await koconutArray
      .flatMap(eachString => eachString)
      // ↑ The string itself can be used as Iterable<string>.
      // If you want to make it clear, also possible to type
      // as eachString => eachString.split('')
      .map(parseInt)
      .yield()
      console.log(allNumberInArray)
      // ↑ [ 1, 2, 3, 4, 5 ]

      // Case 2 - KoconutSet
      const koconutSet = KoconutSet.of("abc", "de")

      const allCharactersInSet = await koconutSet
      .flatMap(eachString => eachString)
      .yield()
      console.log(allCharactersInSet)
      // ↑ [ 'a', 'b', 'c', 'd', 'e' ]

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associateWith(eachNumber => eachNumber * 2)

      const allKeysAndValuesInMap = await koconutMap
      .flatMap(eachEntry => [eachEntry.key, eachEntry.value])
      .yield()
      console.log(allKeysAndValuesInMap)
      // ↑ [1, 2, 2, 4, 3, 6, 4, 8, 5, 10]


      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(123, 987)

      const allDigitsInArray = await koconutArray2
      .flatMap(async eachNumber => {
      const digits = new Array<number>()
      while(eachNumber != 0) {
      digits.unshift(eachNumber % 10)
      eachNumber = Math.floor(eachNumber / 10)
      }
      return digits
      })
      .yield()
      console.log(allDigitsInArray)
      // ↑ [ 1, 2, 3, 9, 8, 7 ]

      const allNumberCharactersInArray = await koconutArray2
      .flatMap(eachNumber => new Promise<string>(resolve => {
      resolve(eachNumber.toString())
      }))
      .yield()
      console.log(allNumberCharactersInArray)
      // ↑ [ '1', '2', '3', '9', '8', '7' ] @@ -510,7 +510,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    flatMapTo

    • flatMapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<Entry<KeyType, ValueType>, Iterable<ResultDataType>>, thisArg?: any): KoconutMap<KeyType, ValueType>

    Returns KoconutArray<ResultDataType>

    flatMapTo

    • flatMapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<Entry<KeyType, ValueType>, Iterable<ResultDataType>>, thisArg?: any): KoconutMap<KeyType, ValueType>
    • Appends all entries yielded from results of transform function being invoked on each entry of original collection, to the given destination.

      since

      1.0.10

      @@ -522,7 +522,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each entry in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    map

    Returns KoconutMap<KeyType, ValueType>

    map

    • Returns a list containing the results of applying the given transform function to each element in the original collection.

      since

      1.0.10

      @@ -532,7 +532,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    mapKeys

    • mapKeys<ResultDataType>(transform: Transformer<Entry<KeyType, ValueType>, ResultDataType>, thisArg?: any): KoconutMap<ResultDataType, ValueType>

    Returns KoconutArray<ResultDataType>

    mapKeys

    • mapKeys<ResultDataType>(transform: Transformer<Entry<KeyType, ValueType>, ResultDataType>, thisArg?: any): KoconutMap<ResultDataType, ValueType>
    • Returns a new Map with entries having the keys obtained by applying the transform function to each entry in this object. The value of each of them would be the same as the original entry.

      @@ -543,7 +543,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each entry in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<ResultDataType, ValueType>

    mapKeysTo

    • mapKeysTo<ResultDataType>(destination: Map<ResultDataType, ValueType>, transform: Transformer<Entry<KeyType, ValueType>, ResultDataType>, thisArg?: any): KoconutMap<KeyType, ValueType>

    Returns KoconutMap<ResultDataType, ValueType>

    mapKeysTo

    • mapKeysTo<ResultDataType>(destination: Map<ResultDataType, ValueType>, transform: Transformer<Entry<KeyType, ValueType>, ResultDataType>, thisArg?: any): KoconutMap<KeyType, ValueType>
    • Populates the given destination map with entries having keys obtained by applying the transform function to each entry in this object. The value of each of them would be the same as the original entry.

      @@ -556,7 +556,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each entry in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    mapNotNull

    • mapNotNull<ResultDataType>(transform: Transformer<Entry<KeyType, ValueType>, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    Returns KoconutMap<KeyType, ValueType>

    mapNotNull

    • mapNotNull<ResultDataType>(transform: Transformer<Entry<KeyType, ValueType>, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>
    • Returns a list containing results that are not null nor undefined of applying the given transfrom function to each element in the original collection. You can use this method as filter then map.

      since

      1.0.10

      @@ -566,7 +566,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    mapNotNullTo

    • mapNotNullTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<Entry<KeyType, ValueType>, null | ResultDataType>, thisArg?: any): KoconutMap<KeyType, ValueType>

    Returns KoconutArray<ResultDataType>

    mapNotNullTo

    • mapNotNullTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<Entry<KeyType, ValueType>, null | ResultDataType>, thisArg?: any): KoconutMap<KeyType, ValueType>
    • Applies the given transform function to each entry of the original collection and appends the results to the given destination.

      since

      1.0.10

      @@ -578,7 +578,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each entry in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    mapTo

    • mapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<Entry<KeyType, ValueType>, ResultDataType>, thisArg?: any): KoconutMap<KeyType, ValueType>

    Returns KoconutMap<KeyType, ValueType>

    mapTo

    • mapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<Entry<KeyType, ValueType>, ResultDataType>, thisArg?: any): KoconutMap<KeyType, ValueType>
    • Applies the given transform function to each entry of the original collection and appends the results to the given destination.

      since

      1.0.10

      @@ -590,7 +590,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    mapValues

    • mapValues<ResultDataType>(transform: Transformer<Entry<KeyType, ValueType>, ResultDataType>, thisArg?: any): KoconutMap<KeyType, ResultDataType>

    Returns KoconutMap<KeyType, ValueType>

    mapValues

    • mapValues<ResultDataType>(transform: Transformer<Entry<KeyType, ValueType>, ResultDataType>, thisArg?: any): KoconutMap<KeyType, ResultDataType>
    • Returns a new Map with entries having the keys of this object and the values obtained by applying the transform function to each entry.

      since

      1.0.10

      @@ -600,7 +600,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each entry in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ResultDataType>

    mapValuesTo

    • mapValuesTo<ResultDataType>(destination: Map<KeyType, ResultDataType>, transform: Transformer<Entry<KeyType, ValueType>, ResultDataType>, thisArg?: any): KoconutMap<KeyType, ValueType>

    Returns KoconutMap<KeyType, ResultDataType>

    mapValuesTo

    • mapValuesTo<ResultDataType>(destination: Map<KeyType, ResultDataType>, transform: Transformer<Entry<KeyType, ValueType>, ResultDataType>, thisArg?: any): KoconutMap<KeyType, ValueType>

    Hierarchy

    Implements

    Index

    Constructors

    Methods Other

    Methods Processor

    Constructors

    constructor

    • new KoconutPair<FirstType, SecondType>(first?: null | FirstType, second?: null | SecondType): KoconutPair<FirstType, SecondType>

    Hierarchy

    Implements

    Index

    Constructors

    Methods Other

    Methods Processor

    Constructors

    constructor

    • new KoconutPair<FirstType, SecondType>(first?: null | FirstType, second?: null | SecondType): KoconutPair<FirstType, SecondType>

    Other Methods

    equalsTo

    Returns KoconutPair<FirstType, SecondType>

    Other Methods

    equalsTo

    Processor Methods

    also

    • also(block: Processor<Pair<FirstType, SecondType>>): Promise<null | Pair<FirstType, SecondType>>

    Returns boolean | KoconutBoolean

    Processor Methods

    also

    • also(block: Processor<Pair<FirstType, SecondType>>): 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 original result.

      since

      1.0.10

      @@ -29,7 +29,7 @@

      Parameters

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

        A callback function that accepts an argument.

        -

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

    let

    • let<ReturnType>(block: Selector<Pair<FirstType, SecondType>, ReturnType>): Promise<ReturnType>

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

    let

    • let<ReturnType>(block: Selector<Pair<FirstType, SecondType>, 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.

      @@ -38,17 +38,17 @@

      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>

    process

    • process(): Promise<void>

    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

    • retrieve(): Promise<KoconutPair<FirstType, SecondType>>

    retrieve

    • retrieve(): Promise<KoconutPair<FirstType, SecondType>>

    yield

    • yield(): Promise<Pair<FirstType, SecondType>>

    yield

    • yield(): Promise<Pair<FirstType, SecondType>>

    Returns KoconutPrimitive<ResultDataType>

    foldIndexed

    • foldIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutPrimitive<ResultDataType>

    Returns KoconutPrimitive<ResultDataType>

    foldIndexed

    • foldIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutPrimitive<ResultDataType>
    • Accumulates value starting with initial value and applying operation from left to right to current accumulator value and each element.

      since

      1.0.10

      @@ -31,7 +31,7 @@ previously returned in the last invocation of the callback or initial value. The method calls the operation one time for each element and index in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the operation. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<ResultDataType>

    Calculator Methods

    count

    Returns KoconutPrimitive<ResultDataType>

    Calculator Methods

    count

    • Returns the number of the elements matching the given predicate. If the predicate is ommitted it'll returns the whole number of elements.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const numberOfAllArrayElements = await koconutArray
      .count()
      .yield()
      console.log(numberOfAllArrayElements)
      // ↑ 5

      const numberOfArrayElementsHigherThan2 = await koconutArray
      .count(eachNumber => eachNumber > 2)
      .yield()
      console.log(numberOfArrayElementsHigherThan2)
      // ↑ 3 -- i.e. [3, 4, 5]

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const numberOfAllSetElements = await koconutSet
      .count()
      .yield()
      console.log(numberOfAllSetElements)
      // ↑ 5

      const numberOfOddSetElements = await koconutSet
      .count(eachNumber => eachNumber % 2 == 1)
      .yield()
      console.log(numberOfOddSetElements)
      // ↑ 3 -- i.e. [1, 3, 5]

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3)
      .associateWith(eachNumber => eachNumber * 2)
      // ↑ Map { 1 => 2,
      // 2 => 4,
      // 3 => 6 }

      const numberOfAllMapEntries = await koconutMap
      .count()
      .yield()
      console.log(numberOfAllMapEntries)
      // ↑ 3

      const numberOfMapEntriesValueHigherThan5 = await koconutMap
      .count(eachEntry => eachEntry.value > 5)
      .yield()
      console.log(numberOfMapEntriesValueHigherThan5)
      // ↑ 1 -- i.e. Entry { 3, 6 }

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(1,2,3,4,5)

      const numberOfArrayElementsLessThan3 = await koconutArray2
      .count(async eachNumber => eachNumber < 3)
      .yield()
      console.log(numberOfArrayElementsLessThan3)
      // ↑ 2 -- i.e. [1, 2]

      const numberOfEvenArrayElements = await koconutArray2
      .count(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 2 == 0)
      }))
      .yield()
      console.log(numberOfEvenArrayElements)
      // ↑ 2 -- i.e. [2, 4] @@ -40,7 +40,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<number>

    maxBy

    Returns KoconutPrimitive<number>

    maxBy

    Returns KoconutPrimitive<DataType>

    maxByOrNull

    Returns KoconutPrimitive<DataType>

    maxByOrNull

    • Returns the first element yielding the largest value of the given function or null if there are no elements.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const largestNumberOfArray = await koconutArray
      .maxByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(largestNumberOfArray)
      // ↑ 5


      const largestNumberOfEmptyArray = await koconutArray
      .filter(eachNumber => eachNumber > 10)
      .maxByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(largestNumberOfEmptyArray)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of("a", "ab", "abc")

      const longestStringOfSet = await koconutSet
      .maxByOrNull(eachString => eachString.length)
      .yield()
      console.log(longestStringOfSet)
      // ↑ abc

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1, 12, 123)
      .associateWith(eachNumber => eachNumber.toString())

      const longestDigitsEntryOfMap = await koconutMap
      .maxByOrNull(eachEntry => eachEntry.value.length)
      .yield()
      console.log(longestDigitsEntryOfMap)
      // ↑ Entry { keyElement: 123, valueElement: '123' }

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(19,27,32)

      const largestNumberOfArray2 = await koconutArray2
      .maxByOrNull(async eachNumber => eachNumber)
      .yield()
      console.log(largestNumberOfArray2)
      // ↑ 32

      const largest1sDigitNumberOfArray2 = await koconutArray2
      .maxByOrNull(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 10)
      }))
      .yield()
      console.log(largest1sDigitNumberOfArray2)
      // ↑ 19 @@ -61,7 +61,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    maxOf

    • maxOf<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutPrimitive<null | DataType>

    maxOf

    • maxOf<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    maxOfOrNull

    • maxOfOrNull<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    maxOfOrNull

    • maxOfOrNull<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>
    • Returns the largest value among all values produced by selector function applied to each element in the collection or null if there are no elements.

      since

      1.0.10

      @@ -82,7 +82,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | string | number | ComparableType>

    maxOfWith

    • maxOfWith<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>

    Returns KoconutPrimitive<null | string | number | ComparableType>

    maxOfWith

    • maxOfWith<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>
    • Returns the largest value according to the provided comparator among all values produced by selector function applied to each element in the collection all throws KoconutNoSuchElementException if elements are empty.

      @@ -99,7 +99,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<ResultDataType>

    maxOfWithOrNull

    • maxOfWithOrNull<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>

    Returns KoconutPrimitive<ResultDataType>

    maxOfWithOrNull

    • maxOfWithOrNull<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>
    • Returns the largest value according to the provided comparator among all values produced by selector function applied to each element in the collection or null if elements are empty.

      @@ -115,7 +115,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | ResultDataType>

    maxWith

    Returns KoconutPrimitive<null | ResultDataType>

    maxWith

    Returns KoconutPrimitive<DataType>

    maxWithOrNull

    Returns KoconutPrimitive<DataType>

    maxWithOrNull

    • Returns the first element having the largest value according to the provided comparator or null if elements are empty.

      since

      1.0.10

      @@ -138,7 +138,7 @@ In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.

    • thisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    minBy

    Returns KoconutPrimitive<null | DataType>

    minBy

    Returns KoconutPrimitive<DataType>

    minByOrNull

    Returns KoconutPrimitive<DataType>

    minByOrNull

    • Returns the first element yielding the smallest value of the given function or null if there are no elements.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const smallestNumberOfArray = await koconutArray
      .minByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(smallestNumberOfArray)
      // ↑ 1

      const smallestNumberOfEmptyArray = await koconutArray
      .filter(eachNumber => eachNumber > 10)
      .minByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(smallestNumberOfEmptyArray)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of("a", "ab", "abc")

      const shortestStringOfSet = await koconutSet
      .minByOrNull(eachString => eachString.length)
      .yield()
      console.log(shortestStringOfSet)
      // ↑ a

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1, 12, 123)
      .associateWith(eachNumber => eachNumber.toString())

      const shortestDigitsEntryOfMap = await koconutMap
      .minByOrNull(eachEntry => eachEntry.value.length)
      .yield()
      console.log(shortestDigitsEntryOfMap)
      // ↑ Entry { keyElement: 1, valueElement: '1' }

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(19,27,32)

      const smallestNumberOfArray2 = await koconutArray2
      .minByOrNull(async eachNumber => eachNumber)
      .yield()
      console.log(smallestNumberOfArray2)
      // ↑ 19

      const smallest1sDigitNumberOfArray2 = await koconutArray2
      .minByOrNull(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 10)
      }))
      .yield()
      console.log(smallest1sDigitNumberOfArray2)
      // ↑ 32 @@ -159,7 +159,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    minOf

    • minOf<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutPrimitive<null | DataType>

    minOf

    • minOf<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    minOfOrNull

    • minOfOrNull<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    minOfOrNull

    • minOfOrNull<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>
    • Returns the smallest value among all values produced by selector function applied to each element in the collection or null if there are no elements.

      since

      1.0.10

      @@ -180,7 +180,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | string | number | ComparableType>

    minOfWith

    • minOfWith<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>

    Returns KoconutPrimitive<null | string | number | ComparableType>

    minOfWith

    • minOfWith<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>
    • Returns the smallest value according to the provided comparator among all values produced by selector function applied to each element in the collection all throws KoconutNoSuchElementException if elements are empty.

      @@ -197,7 +197,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<ResultDataType>

    minOfWithOrNull

    • minOfWithOrNull<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>

    Returns KoconutPrimitive<ResultDataType>

    minOfWithOrNull

    • minOfWithOrNull<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>
    • Returns the smallest value according to the provided comparator among all values produced by selector function applied to each element in the collection all null if elements are empty.

      @@ -214,7 +214,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | ResultDataType>

    minWith

    Returns KoconutPrimitive<null | ResultDataType>

    minWith

    Returns KoconutPrimitive<DataType>

    minWithOrNull

    Returns KoconutPrimitive<DataType>

    minWithOrNull

    • Returns the first element having the smallest value according to the provided comparator or null if elements are empty.

      since

      1.0.10

      @@ -237,24 +237,24 @@ In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.

    • thisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    Caster Methods

    asArray

    Returns KoconutPrimitive<null | DataType>

    Caster Methods

    asArray

    • Creates an KoconutArray instance that wraps original data.

      since

      1.0.13

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const arrToArr = await koconutArray
      .asArray()
      .yield()
      console.log(arrToArr)
      // ↑ [ 1, 2, 3, 4, 5 ]

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,1,2,2,3,3,4,4,5,5)

      const setToArr = await koconutSet
      .asArray()
      .yield()
      console.log(setToArr)
      // ↑ [ 1, 2, 3, 4, 5 ]

      // Case 3 -- KoconutFlow
      const koconutFlow = KoconutFlow.ofSimple(1,2,3,4,5)

      const flowToArr = await koconutFlow
      .asArray()
      .yield()
      console.log(flowToArr)
      // ↑
      // [
      // Entry { keyElement: 0, valueElement: 1 },
      // Entry { keyElement: 1, valueElement: 2 },
      // Entry { keyElement: 2, valueElement: 3 },
      // Entry { keyElement: 3, valueElement: 4 },
      // Entry { keyElement: 4, valueElement: 5 }
      // ]

      // Case 4 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber])

      const mapToArr = await koconutMap
      .asArray()
      .yield()
      console.log(mapToArr)
      // ↑
      // [
      // Entry { keyElement: 1, valueElement: 1 },
      // Entry { keyElement: 2, valueElement: 2 },
      // Entry { keyElement: 3, valueElement: 3 },
      // Entry { keyElement: 4, valueElement: 4 },
      // Entry { keyElement: 5, valueElement: 5 }
      // ]
      -

      Returns KoconutArray<DataType>

    asSet

    asSet

    • Creates an KoconutSet instance that wraps original data.

      since

      1.0.13

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const arrToSet = await koconutArray
      .asSet()
      .yield()
      console.log(arrToSet)
      // ↑ Set { 1, 2, 3, 4, 5 }

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,1,2,2,3,3,4,4,5,5)

      const setToSet = await koconutSet
      .asSet()
      .yield()
      console.log(setToSet)
      // ↑ Set { 1, 2, 3, 4, 5 }

      // Case 3 -- KoconutFlow
      const koconutFlow = KoconutFlow.ofSimple(1,2,3,4,5)

      const flowToSet = await koconutFlow
      .asSet()
      .yield()
      console.log(flowToSet)
      // ↑
      // Set {
      // Entry { keyElement: 0, valueElement: 1 },
      // Entry { keyElement: 1, valueElement: 2 },
      // Entry { keyElement: 2, valueElement: 3 },
      // Entry { keyElement: 3, valueElement: 4 },
      // Entry { keyElement: 4, valueElement: 5 }
      // }

      // Case 4 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber])

      const mapToSet = await koconutMap
      .asSet()
      .yield()
      console.log(mapToSet)
      // ↑
      // Set {
      // Entry { keyElement: 1, valueElement: 1 },
      // Entry { keyElement: 2, valueElement: 2 },
      // Entry { keyElement: 3, valueElement: 3 },
      // Entry { keyElement: 4, valueElement: 4 },
      // Entry { keyElement: 5, valueElement: 5 }
      // }
      -

      Returns KoconutSet<DataType>

    Creator Methods

    Static from

    • from<DataType>(source?: null | Iterable<DataType>): KoconutSet<DataType>

    Creator Methods

    Static from

    • from<DataType>(source?: null | Iterable<DataType>): KoconutSet<DataType>
    • Creates a new instance from iterable object.

      since

      1.0.11

      example
      const numbers = Array.of(1,2,3,4,5)
      const koconutNumbers = KoconutSet.from(numbers)
      // ↑ This is a Koconut number set consists of 1 to 5.

      const emptyNumberSet = KoconutSet.from<number>()
      // ↑ This is an empty Koconut number set.

      Type parameters

      • DataType

      Parameters

      • source: null | Iterable<DataType> = null

        An array-like iterable object to convert to a KoconutSet.

        -

      Returns KoconutSet<DataType>

    Static generate

    • generate<DataType>(count: number, generator: Generator<DataType>, thisArg?: any): KoconutSet<DataType>

    Returns KoconutSet<DataType>

    Static generate

    • generate<DataType>(count: number, generator: Generator<DataType>, thisArg?: any): KoconutSet<DataType>
    • Creates a new instance with given count as number of values. count cannot be negative number. Each value is provided from generator with given ordered index.

      throws

      KoconutInvalidArgumentException @@ -268,14 +268,14 @@

      A callback function that accepts an argument. The method calls the action one time for each ordered index.

    • thisArg: any = null

      An object to which the this keyword can refer in the generator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    Static of

    • of<DataType>(...data: DataType[]): KoconutSet<DataType>

    Returns KoconutSet<DataType>

    Static of

    • of<DataType>(...data: DataType[]): KoconutSet<DataType>
    • Creates a new instance from variable number of arguments.

      since

      1.0.11

      example
      const koconutNumbers = KoconutSet.of(1,2,3,4,5)
      // ↑ This is a Koconut number set consists of 1 to 5.

      const emptyNumberSet = KoconutSet.of<number>()
      // ↑ This is an empty Koconut number set.

      Type parameters

      • DataType

      Parameters

      • Rest ...data: DataType[]

        A set of elements to include in the new KoconutSet object.

        -

      Returns KoconutSet<DataType>

    Inspector Methods

    all

    Returns KoconutSet<DataType>

    Inspector Methods

    all

    • Return true if all elements match te given predicate.

      since

      1.0.10

      example
        // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const areAllArrayElementsGreaterThan0 = await koconutArray
      .all(eachNumber => eachNumber > 0)
      .yield()
      console.log(areAllArrayElementsGreaterThan0)
      // ↑ true

      const areAllArrayElementsEven = await koconutArray
      .all(eachNumber => eachNumber % 2 == 0)
      .yield()
      console.log(areAllArrayElementsEven)
      // ↑ false -- i.e. '1' is not an even number.


      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const areAllSetElementsGreaterThan0 = await koconutSet
      .all(eachNumber => eachNumber > 0)
      .yield()
      console.log(areAllSetElementsGreaterThan0)
      // ↑ true

      const areAllSetElementsOdd = await koconutSet
      .all(eachNumber => eachNumber % 2 == 1)
      .yield()
      console.log(areAllSetElementsOdd)
      // ↑ false -- i.e. '2' is not an odd number.


      // Case 3 -- KoconutMap
      const koconutMap = KoconutMap.of(
      [0, 0],
      [1, 1],
      [2, 2]
      )

      const areAllMapEntriesKeyEqualsToValue = await koconutMap
      .all(eachEntry => eachEntry.key == eachEntry.value)
      .yield()
      console.log(areAllMapEntriesKeyEqualsToValue)
      // ↑ true

      const areAllMapEntriesSumGreaterThan3 = await koconutMap
      .all(eachEntry => eachEntry.key + eachEntry.value > 3)
      .yield()
      console.log(areAllMapEntriesSumGreaterThan3)
      // ↑ false -- i.e. Sum of key and value of first Entry { 0, 0 } is 0.
      // It's definetly less than 3

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(1,2,3,4,5)

      const areAllArrayElementsLessThan10 = await koconutArray2
      .all(async eachNumber => eachNumber < 10)
      .yield()
      console.log(areAllArrayElementsLessThan10)
      // ↑ true

      const areAllArrayElementsOdd = await koconutArray2
      .all(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 2 == 1)
      }))
      .yield()
      console.log(areAllArrayElementsOdd)
      // ↑ false -- i.e. '2' is not an odd number. @@ -284,7 +284,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutBoolean

    any

    Returns KoconutBoolean

    any

    • Returns true if the collection has at least one element matches the given predicate.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isAnyArrayElementGreaterThan4 = await koconutArray
      .any(eachNumber => eachNumber > 4)
      .yield()
      console.log(isAnyArrayElementGreaterThan4)
      // ↑ true -- i.e. '5' is greater than 4.

      const isAnyArrayElementMultipleOf6 = await koconutArray
      .any(eachNumber => eachNumber % 6 == 0)
      .yield()
      console.log(isAnyArrayElementMultipleOf6)
      // ↑ false

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isAnySetElementGreaterThan3 = await koconutSet
      .any(eachNumber => eachNumber > 3)
      .yield()
      console.log(isAnySetElementGreaterThan3)
      // ↑ true -- i.e. '4' is greater than 3.

      const isAnySetElementLessThan0 = await koconutSet
      .any(eachNumber => eachNumber < 0)
      .yield()
      console.log(isAnySetElementLessThan0)
      // ↑ false

      // Case 3 -- KoconutMap
      const koconutMap = KoconutMap.of(
      [0, 0],
      [1, 1],
      [2, 2]
      )

      const isAnyMapEntrySumGreaterThan3 = await koconutMap
      .any(eachEntry => eachEntry.key + eachEntry.value > 3)
      .yield()
      console.log(isAnyMapEntrySumGreaterThan3)
      // ↑ true -- i.e. Sum of key and value of third Entry { 2, 2 } is 4.
      // It's grater than 4.

      const isAnyMapEntryKeyMultipleOf4 = await koconutMap
      .any(eachEntry => eachEntry.key > 0 && eachEntry.key % 4 == 0)
      .yield()
      console.log(isAnyMapEntryKeyMultipleOf4)
      // ↑ false

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(1,2,3,4,5)

      const isAnyArrayElementLessThan2 = await koconutArray2
      .any(async eachNumber => eachNumber < 2)
      .yield()
      console.log(isAnyArrayElementLessThan2)
      // ↑ true -- i.e. '1' is less than 2.

      const isAnyArrayElementGreaterThan7 = await koconutArray2
      .any(eachNumber => new Promise(resolve => {
      resolve(eachNumber > 7)
      }))
      .yield()
      console.log(isAnyArrayElementGreaterThan7)
      // ↑ false @@ -293,38 +293,38 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutBoolean

    contains

    Returns KoconutBoolean

    contains

    • Checks if the specified element is contained in this collection.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const doesArrayContain3 = await koconutArray
      .contains(3)
      .yield()
      console.log(doesArrayContain3)
      // ↑ true

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const doesSetContains6 = await koconutSet
      .contains(6)
      .yield()
      console.log(doesSetContains6)
      // ↑ false

      Parameters

      • element: DataType

        The element to search for.

        -

      Returns KoconutBoolean

    containsAll

    Returns KoconutBoolean

    containsAll

    • Checks if all the elements are contained in this collection.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const doesArrayContain1to3 = await koconutArray
      .containsAll([1,2,3])
      .yield()
      console.log(doesArrayContain1to3)
      // ↑ true

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const doesSetContains5to6 = await koconutSet
      .containsAll([5,6,7])
      .yield()
      console.log(doesSetContains5to6)
      // ↑ false

      Parameters

      • elements: Iterable<DataType>

        The elements to search for.

        -

      Returns KoconutBoolean

    isEmpty

    Returns KoconutBoolean

    isEmpty

    • Returns true if the collection is empty (contains no elements), false otherwise.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isNumberArrayEmpty = await koconutArray
      .isEmpty()
      .yield()
      console.log(isNumberArrayEmpty)
      // ↑ false

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isFilteredNumberSetEmpty = await koconutSet
      .filter(eachNumber => eachNumber > 10)
      .isEmpty()
      .yield()
      console.log(isFilteredNumberSetEmpty)
      // ↑ true

      // Case 3 -- KoconutMap
      const koconutMap = new KoconutMap<number, number>()

      const isNumberPairedMapEmpty = await koconutMap
      .isEmpty()
      .yield()
      console.log(isNumberPairedMapEmpty)
      // ↑ true
      -

      Returns KoconutBoolean

    isNotEmpty

    isNotEmpty

    • Returns true if the collection is not empty.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isNumberArrayEmpty = await koconutArray
      .isNotEmpty()
      .yield()
      console.log(isNumberArrayEmpty)
      // ↑ true

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isFilteredNumberSetEmpty = await koconutSet
      .filter(eachNumber => eachNumber > 10)
      .isNotEmpty()
      .yield()
      console.log(isFilteredNumberSetEmpty)
      // ↑ false

      // Case 3 -- KoconutMap
      const koconutMap = new KoconutMap<number, number>()

      const isNumberPairedMapEmpty = await koconutMap
      .isNotEmpty()
      .yield()
      console.log(isNumberPairedMapEmpty)
      // ↑ false
      -

      Returns KoconutBoolean

    isNullOrEmpty

    isNullOrEmpty

    • Returns true if this nullable collection is either null or empty.

      since

      1.0.10

      deprecated

      Use isEmpty instead.

      until

      1.3.0

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isNumberArrayEmpty = await koconutArray
      .isNullOrEmpty()
      .yield()
      console.log(isNumberArrayEmpty)
      // ↑ false

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isFilteredNumberSetEmpty = await koconutSet
      .filter(eachNumber => eachNumber > 10)
      .isNullOrEmpty()
      .yield()
      console.log(isFilteredNumberSetEmpty)
      // ↑ true

      // Case 3 -- KoconutMap
      const koconutMap = new KoconutMap<number, number>()

      const isNumberPairedMapEmpty = await koconutMap
      .isNullOrEmpty()
      .yield()
      console.log(isNumberPairedMapEmpty)
      // ↑ true
      -

      Returns KoconutBoolean

    none

    none

    • predicate callback function is optional. If it's omitted the method returns true if the collection has no elements. Otherwise, returns true if no elements match the given predicate.

      since

      1.0.10

      @@ -334,7 +334,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutBoolean

    Iterator Methods

    forEach

    Returns KoconutBoolean

    Iterator Methods

    forEach

    • Performs the given action on each element. When you want to stop iteration in the meantime return false or KoconutLoopSignal.BREAK.

      since

      1.0.10

      @@ -344,7 +344,7 @@

      A callback function that accepts an argument. The method calls the action one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the action. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<void>

    forEachIndexed

    Returns KoconutPrimitive<void>

    forEachIndexed

    • Performs the given action on each element, providing sequential index with the element. When you want to stop iteration in the meantime return false or KoconutLoopSignal.BREAK.

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5,6,7)

      await koconutArray
      .forEachIndexed(console.log)
      // ↑ 0 1
      // 1 2
      // 2 3
      // 3 4
      // 4 5
      // 5 6
      // 6 7
      .process()

      await koconutArray
      .forEachIndexed((eachIndex, eachNumber) => {
      if(eachIndex == 3) return KoconutLoopSignal.BREAK
      console.log(eachNumber)
      })
      // ↑ 1 2 3 -- i.e. Since when the index is '3', the loop is interrupted.
      // The last printed number(element) would be '3'.
      .process()

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,1,2,3)

      await koconutSet
      .forEachIndexed(console.log)
      // ↑ 0 1
      // 1 2
      // 2 3
      .process()

      await koconutSet
      .forEachIndexed((eachIndex, eachNumber) => {
      if(eachIndex != 0 && eachIndex % 2 == 0) return false
      console.log(eachNumber)
      })
      // ↑ 1 2 -- i.e. Since when the index '2', it's an even number.
      // So the loop is interrupted.
      // The last printed number(element) would be '2'
      .process()

      // Case 3 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(1,2,3)

      await koconutArray2
      .forEachIndexed(async (eachIndex, eachNumber) =>
      console.log(eachIndex, eachNumber))
      // ↑ 0 1
      // 1 2
      // 2 3
      .process()

      await koconutArray2
      .forEachIndexed(async (eachIndex, eachNumber) => new Promise(resolve => {
      resolve(console.log(eachIndex, eachNumber))
      }))
      // ↑ 0 1
      // 1 2
      // 2 3
      .process() @@ -353,7 +353,7 @@

      A callback function that accepts two arguments. The method calls the action one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the action. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<void>

    onEach

    Returns KoconutPrimitive<void>

    onEach

    • Perfroms the given action on each element and returns the original collection itself afterwards. When you want to stop iteration in the meantime return false or KoconutLoopSignal.BREAK.

      since

      1.0.10

      @@ -363,7 +363,7 @@

      A callback function that accepts an argument. The method calls the action one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the action. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    onEachIndexed

    Returns KoconutSet<DataType>

    onEachIndexed

    • Performs the given action on each element, providing sequential index with the element, and returns the collection itself afterwards. When you want to stop iteration in the meantime return false or KoconutLoopSignal.BREAK.

      since

      1.0.10

      @@ -373,14 +373,14 @@

      A callback function that accepts two arguments. The method calls the action one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the action. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    Manipulator Methods

    distinct

    Returns KoconutSet<DataType>

    Manipulator Methods

    distinct

    • Returns a KoconutSet containing only distinct elements from this collection. If the type of data is a simple number or string, the method will check equality by using '==' operator, but if it's not, you'd better make your custom class inherits KoconutEquatable.

      since

      1.0.10

      example
      const numberKoconutSet = KoconutSet.of(1,1,2,2,3,3)

      const distinctNumbers = await numberKoconutSet
      .distinct()
      .yield()
      console.log(distinctNumbers)
      // ↑ Set { 1, 2, 3 }

      class SomeInfo {
      info : string
      constructor(info : string) {
      this.info = info
      }
      }
      const someInfoKoconutSet = KoconutSet.of(
      new SomeInfo("A"),
      new SomeInfo("A"),
      new SomeInfo("B"),
      new SomeInfo("B"),
      new SomeInfo("C"),
      new SomeInfo("C"),
      )
      const distinctSomeInfos = await someInfoKoconutSet
      .distinct()
      .yield()
      console.log(distinctSomeInfos)
      // ↑ Set {
      // SomeInfo { info: 'A' },
      // SomeInfo { info: 'A' },
      // SomeInfo { info: 'B' },
      // SomeInfo { info: 'B' },
      // SomeInfo { info: 'C' },
      // SomeInfo { info: 'C' }
      // }

      class SomeEquatableInfo implements KoconutEquatable {
      info : string
      constructor(info : string) {
      this.info = info
      }
      equalsTo(other : SomeEquatableInfo) : boolean {
      return this.info == other.info
      }
      }
      const someEquatableInfoKoconutSet = KoconutSet.of(
      new SomeEquatableInfo("A"),
      new SomeEquatableInfo("A"),
      new SomeEquatableInfo("B"),
      new SomeEquatableInfo("B"),
      new SomeEquatableInfo("C"),
      new SomeEquatableInfo("C")
      )
      const distinctSomeEquatableInfos = await someEquatableInfoKoconutSet
      .distinct()
      .yield()
      console.log(distinctSomeEquatableInfos)
      // ↑ Set {
      // SomeEquatableInfo { info: 'A' },
      // SomeEquatableInfo { info: 'B' },
      // SomeEquatableInfo { info: 'C' }
      // }
      -

      Returns KoconutSet<DataType>

    distinctBy

    • distinctBy<KeyType, EquatableKeyType>(selector: Selector<DataType, KeyType | EquatableKeyType>, thisArg?: any): KoconutSet<DataType>

    distinctBy

    • distinctBy<KeyType, EquatableKeyType>(selector: Selector<DataType, KeyType | EquatableKeyType>, thisArg?: any): KoconutSet<DataType>
    • Returns a KoconutSet containing only elements from the given collection having distinct keys returned by the given selector function.

      since

      1.0.10

      @@ -390,21 +390,21 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value

      -

    Returns KoconutSet<DataType>

    drop

    Returns KoconutSet<DataType>

    drop

    dropLast

    Returns KoconutSet<DataType>

    dropLast

    dropLastWhile

    Returns KoconutSet<DataType>

    dropLastWhile

    • Returns a KoconutSet containing all elements except last elements that satisfy the given predicate.

      since

      1.0.10

      example
      const koconutSet = KoconutSet.of(
      1,2,3,4,5,6,7,8,9,10
      )

      const greaterThan5DroppedSet = await koconutSet
      .dropLastWhile(eachNumber => eachNumber > 5)
      .yield()
      console.log(greaterThan5DroppedSet)
      // ↑ Set { 1, 2, 3, 4, 5 } @@ -413,7 +413,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    dropWhile

    Returns KoconutSet<DataType>

    dropWhile

    • Returns a KoconutSet containing all elements except first elements that satisfy the given predicate.

      since

      1.0.10

      example
      const koconutSet = KoconutSet.of(
      1,2,3,4,5,6,7,8,9,10
      )

      const lessThan5DroppedSet = await koconutSet
      .dropWhile(eachNumber => eachNumber < 5)
      .yield()
      console.log(lessThan5DroppedSet)
      // ↑ Set { 5, 6, 7, 8, 9, 10 } @@ -422,7 +422,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    filter

    Returns KoconutSet<DataType>

    filter

    • Returns a KoconutSet containing only elements matching the given predicate.

      since

      1.0.10

      example
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const evenNumbers = await koconutSet
      .filter(eachNumber => eachNumber % 2 == 0)
      .yield()
      console.log(evenNumbers)
      // ↑ Set { 2, 4 } @@ -431,7 +431,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    filterIndexed

    Returns KoconutSet<DataType>

    filterIndexed

    • Returns a KoconutSet containing only elements matching the given predicate with indexes.

      since

      1.0.10

      example
      const koconutSet = KoconutSet.of(0,1,2,5,6,7)

      const numbersEqualToIndex = await koconutSet
      .filterIndexed((eachIndex, eachNumber) => eachIndex == eachNumber)
      .yield()
      console.log(numbersEqualToIndex)
      // ↑ Set { 0, 1, 2 } @@ -440,7 +440,7 @@

      A callback function that accepts two arguments. The method calls the predicate one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    filterIndexedTo

    Returns KoconutSet<DataType>

    filterIndexedTo

    • Appends all elements matching the given predicate with indexes to the given destination.

      since

      1.0.10

      example
      const koconutSet = KoconutSet.of(0,1,2,5,6,7)

      const numbersEqualToIndex = new Array<number>()
      const origianlData =await koconutSet
      .filterIndexedTo(
      numbersEqualToIndex,
      (eachIndex, eachNumber) => eachIndex == eachNumber
      )
      .yield()
      console.log(numbersEqualToIndex)
      // ↑ [ 0, 1, 2 ]
      console.log(origianlData)
      // ↑ Set { 0, 1, 2, 5, 6, 7 } @@ -451,7 +451,7 @@

      A callback function that accepts two arguments. The method calls the predicate one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    filterNot

    Returns KoconutSet<DataType>

    filterNot

    • Returns a KoconutSet containing only elements not matching the given predicate.

      since

      1.0.10

      example
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const oddNumbers = await koconutSet
      .filterNot(eachNumber => eachNumber % 2 == 0)
      .yield()
      console.log(oddNumbers)
      // ↑ Set { 1, 3, 5 } @@ -460,19 +460,19 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    filterNotNull

    Returns KoconutSet<DataType>

    filterNotNull

    filterNotNullTo

    • filterNotNullTo(destination: Set<DataType> | DataType[]): KoconutSet<DataType>

    filterNotNullTo

    • filterNotNullTo(destination: Set<DataType> | DataType[]): KoconutSet<DataType>
    • Appends all elements that are not null to the given destination.

      since

      1.0.10

      example
      const koconutSet = KoconutSet.of(1,2,null,null)

      const numbers = Array<number>()
      const originalData = await koconutSet
      .filterNotNullTo(numbers)
      .yield()
      console.log(numbers)
      // ↑ [ 1, 2 ]
      console.log(originalData)
      // ↑ Set { 1, 2, null }

      Parameters

      • destination: Set<DataType> | DataType[]

        Iterable destinaion. Array or Set to be exact.

        -

      Returns KoconutSet<DataType>

    filterNotTo

    • filterNotTo(destination: Set<DataType> | DataType[], predicate: Predicator<DataType>, thisArg?: any): KoconutSet<DataType>

    Returns KoconutSet<DataType>

    filterNotTo

    • filterNotTo(destination: Set<DataType> | DataType[], predicate: Predicator<DataType>, thisArg?: any): KoconutSet<DataType>
    • Appends all elements not matching the given predicate to the given destination.

      since

      1.0.10

      example
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const oddNumbers = new Array<number>()
      const originalData = await koconutSet
      .filterTo(
      oddNumbers,
      eachNumber => eachNumber % 2 == 0
      )
      .yield()
      console.log(oddNumbers)
      // ↑ [ 1, 3, 5 ]
      console.log(originalData)
      // ↑ Set { 1, 2, 3, 4, 5 } @@ -483,7 +483,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    filterTo

    • filterTo(destination: Set<DataType> | DataType[], predicate: Predicator<DataType>, thisArg?: any): KoconutSet<DataType>

    Returns KoconutSet<DataType>

    filterTo

    • filterTo(destination: Set<DataType> | DataType[], predicate: Predicator<DataType>, thisArg?: any): KoconutSet<DataType>
    • Appends all elements matching the given predicate to the given destination.

      since

      1.0.10

      example
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const evenNumbers = new Array<number>()
      const originalData = await koconutSet
      .filterTo(
      evenNumbers,
      eachNumber => eachNumber % 2 == 0
      )
      .yield()
      console.log(evenNumbers)
      // ↑ [ 2, 4 ]
      console.log(originalData)
      // ↑ Set { 1, 2, 3, 4, 5 } @@ -494,7 +494,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    sortedBy

    Returns KoconutSet<DataType>

    sortedBy

    • Returns a KoconutSet of all elements sorted according to natural sort order of the value returned by specified selector function. It could be either a number, string, or custom class that inherits KoconutComparable.

      @@ -505,7 +505,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value

      -

    Returns KoconutSet<DataType>

    sortedByDescending

    Returns KoconutSet<DataType>

    sortedByDescending

    • Returns a KoconutSet of all elements sorted descending according to natural sort order of the value returned by specified selector function. It could be either a number, string, or custom class that inherits KoconutComparable.

      @@ -516,7 +516,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value

      -

    Returns KoconutSet<DataType>

    sortedWith

    Returns KoconutSet<DataType>

    sortedWith

    • Returns a KoconutSet of all elements sorted according to the specified comparator.

      since

      1.0.10

      @@ -527,21 +527,21 @@ In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.

    • thisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value

      -

    Returns KoconutSet<DataType>

    take

    Returns KoconutSet<DataType>

    take

    takeLast

    Returns KoconutSet<DataType>

    takeLast

    takeLastWhile

    Returns KoconutSet<DataType>

    takeLastWhile

    • Returns a KoconutSet containing last elements satisfying the given predicate.

      since

      1.0.10

      example
      const koconutSet = KoconutSet.of(
      1,2,3,4,5,6,7,8,9,10
      )

      const lastNumbersWhileGreaterThan7 = await koconutSet
      .takeLastWhile(eachNumber => eachNumber >7)
      .yield()
      console.log(lastNumbersWhileGreaterThan7)
      // ↑ Set { 8, 9, 10 } @@ -550,7 +550,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    takeWhile

    Returns KoconutSet<DataType>

    takeWhile

    • Returns a KoconutSet containing first elements satisfying the given predicate.

      since

      1.0.10

      example
      const koconutSet = KoconutSet.of(
      1,2,3,4,5,6,7,8,9,10
      )

      const numbersWhileLessThan5 = await koconutSet
      .takeWhile(eachNumber => eachNumber < 5)
      .yield()
      console.log(numbersWhileLessThan5)
      // ↑ Set { 1, 2, 3, 4 } @@ -559,7 +559,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    Other Methods

    indices

    intersect

    • intersect(other: Iterable<DataType>): KoconutSet<DataType>

    join

    • join(separator?: string, prefix?: string, postfix?: string, limit?: number, truncated?: string, transform?: null | Transformer<DataType, any>, thisArg?: any): KoconutPrimitive<string>

    last

    lastIndexOf

    lastOrNull

    minus

    • minus(element: DataType): KoconutSet<DataType>
    • minus(elements: Iterable<DataType>): KoconutSet<DataType>

    minusElement

    • minusElement(element: DataType): KoconutSet<DataType>

    partition

    plus

    • plus(element: DataType): KoconutSet<DataType>
    • plus(elements: Iterable<DataType>): KoconutSet<DataType>

    plusElement

    • plusElement(element: DataType): KoconutSet<DataType>

    random

    randomOrNull

    reduce

    reduceIndexed

    reduceIndexedOrNull

    reduceOrNull

    reversed

    runningFold

    • runningFold<ResultDataType>(initial: ResultDataType, operation: Operator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    runningFoldIndexed

    • runningFoldIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    runningReduce

    runningReduceIndexed

    scan

    • scan<ResultDataType>(initial: ResultDataType, operation: Operator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    scanIndexed

    • scanIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    shuffled

    single

    singleOrNull

    size

    subtract

    • subtract(other: Iterable<DataType>): KoconutSet<DataType>

    sumBy

    union

    • union(other: Iterable<DataType>): KoconutSet<DataType>

    validate

    • validate(data: null | Set<DataType>): Promise<void>

    windowed

    • windowed<ResultDataType>(size: number, step: number, partialWindows: boolean, transform: null | Transformer<DataType[], ResultDataType>, thisArg: any): KoconutArray<DataType[] | ResultDataType>

    withIndex

    zip

    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: null | Zipper<DataType, OtherDataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType | Pair<DataType, OtherDataType>>
    • zip<OtherDataType>(other: Iterable<OtherDataType>): KoconutArray<Pair<DataType, OtherDataType>>
    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: Zipper<DataType, OtherDataType, ResultDataType>): KoconutArray<ResultDataType>
    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: Zipper<DataType, OtherDataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType>

    zipWithNext

    • zipWithNext<ResultDataType>(transform: null | Zipper<DataType, DataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType | Pair<DataType, DataType>>
    • zipWithNext(): KoconutArray<Pair<DataType, DataType>>
    • zipWithNext<ResultDataType>(transform: Zipper<DataType, DataType, ResultDataType>): KoconutArray<ResultDataType>
    • zipWithNext<ResultDataType>(transform: Zipper<DataType, DataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType>

    Processor Methods

    also

    • also(block: Processor<Set<DataType>>): Promise<null | Set<DataType>>

    Returns KoconutSet<DataType>

    Other Methods

    indices

    intersect

    • intersect(other: Iterable<DataType>): KoconutSet<DataType>

    join

    • join(separator?: string, prefix?: string, postfix?: string, limit?: number, truncated?: string, transform?: null | Transformer<DataType, any>, thisArg?: any): KoconutPrimitive<string>

    last

    lastIndexOf

    lastOrNull

    minus

    • minus(element: DataType): KoconutSet<DataType>
    • minus(elements: Iterable<DataType>): KoconutSet<DataType>

    minusElement

    • minusElement(element: DataType): KoconutSet<DataType>

    partition

    plus

    • plus(element: DataType): KoconutSet<DataType>
    • plus(elements: Iterable<DataType>): KoconutSet<DataType>

    plusElement

    • plusElement(element: DataType): KoconutSet<DataType>

    random

    randomOrNull

    reduce

    reduceIndexed

    reduceIndexedOrNull

    reduceOrNull

    reversed

    runningFold

    • runningFold<ResultDataType>(initial: ResultDataType, operation: Operator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    runningFoldIndexed

    • runningFoldIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    runningReduce

    runningReduceIndexed

    scan

    • scan<ResultDataType>(initial: ResultDataType, operation: Operator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    scanIndexed

    • scanIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    shuffled

    single

    singleOrNull

    size

    subtract

    • subtract(other: Iterable<DataType>): KoconutSet<DataType>

    sumBy

    union

    • union(other: Iterable<DataType>): KoconutSet<DataType>

    validate

    • validate(data: null | Set<DataType>): Promise<void>

    windowed

    • windowed<ResultDataType>(size: number, step: number, partialWindows: boolean, transform: null | Transformer<DataType[], ResultDataType>, thisArg: any): KoconutArray<DataType[] | ResultDataType>

    withIndex

    zip

    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: null | Zipper<DataType, OtherDataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType | Pair<DataType, OtherDataType>>
    • zip<OtherDataType>(other: Iterable<OtherDataType>): KoconutArray<Pair<DataType, OtherDataType>>
    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: Zipper<DataType, OtherDataType, ResultDataType>): KoconutArray<ResultDataType>
    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: Zipper<DataType, OtherDataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType>

    zipWithNext

    • zipWithNext<ResultDataType>(transform: null | Zipper<DataType, DataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType | Pair<DataType, DataType>>
    • zipWithNext(): KoconutArray<Pair<DataType, DataType>>
    • zipWithNext<ResultDataType>(transform: Zipper<DataType, DataType, ResultDataType>): KoconutArray<ResultDataType>
    • zipWithNext<ResultDataType>(transform: Zipper<DataType, DataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType>

    Processor Methods

    also

    • also(block: Processor<Set<DataType>>): Promise<null | Set<DataType>>
    • 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

      @@ -567,7 +567,7 @@

      Parameters

      • block: Processor<Set<DataType>>

        A callback function that accepts an argument.

        -

      Returns Promise<null | Set<DataType>>

    let

    • let<ReturnType>(block: Selector<Set<DataType>, ReturnType>): Promise<ReturnType>

    Returns Promise<null | Set<DataType>>

    let

    • let<ReturnType>(block: Selector<Set<DataType>, 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.

      @@ -576,22 +576,22 @@

      Type parameters

      • ReturnType

      Parameters

      • block: Selector<Set<DataType>, ReturnType>

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

        -

      Returns Promise<ReturnType>

    process

    • process(): Promise<void>

    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

    retrieve

    yield

    • yield(): Promise<Set<DataType>>

    yield

    • yield(): Promise<Set<DataType>>
    • 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<Set<DataType>>

    Selector Methods

    elementAt

    Selector Methods

    elementAt

    elementAtOrElse

    Returns KoconutPrimitive<DataType>

    elementAtOrElse

    • Returns an element at the given index or the result of calling the defaultValue function if the index is out of bounds of this collection.

      since

      1.0.10

      @@ -612,14 +612,14 @@

      A callback function that accepts an argument. The method calls the defaultValue function when index is out of bounds.

    • thisArg: any = null

      An object to which the this keyword can refer in the defaultValue. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<DataType>

    elementAtOrNull

    Returns KoconutPrimitive<DataType>

    elementAtOrNull

    • Returns an element at the given index or null if the index is out of bounds of this collection.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const elementAtIndex3OfArray = await koconutArray
      .elementAtOrNull(3)
      .yield()
      console.log(elementAtIndex3OfArray)
      // ↑ 4

      const elementAtIndex10OfArray = await koconutArray
      .elementAtOrNull(10)
      .yield()
      console.log(elementAtIndex10OfArray)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const elementAtIndex2OfSet = await koconutSet
      .elementAtOrNull(2)
      .yield()
      console.log(elementAtIndex2OfSet)
      // ↑ 3

      const elementAtIndexNegative2OfSet = await koconutSet
      .elementAtOrNull(-2)
      .yield()
      console.log(elementAtIndexNegative2OfSet)
      // ↑ null

      Parameters

      • index: number

        The index of element to search for.

        -

      Returns KoconutPrimitive<null | DataType>

    find

    Returns KoconutPrimitive<null | DataType>

    find

    • Returns the first element matching the given predicate, or null if no such element was found.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const foundEventNumberOfArray = await koconutArray
      .find(eachNumber => eachNumber % 2 == 0)
      .yield()
      console.log(foundEventNumberOfArray)
      // ↑ 2

      const foundMultiplesOf10Array = await koconutArray
      .find(eachNumber => eachNumber % 10 == 0)
      .yield()
      console.log(foundMultiplesOf10Array)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const foundOddNumberOfSet = await koconutSet
      .find(eachNumber => eachNumber % 2 == 1)
      .yield()
      console.log(foundOddNumberOfSet)
      // ↑ 1

      const foundMultiplesOf10OfSet = await koconutSet
      .find(eachNumber => eachNumber % 10 == 0)
      .yield()
      console.log(foundMultiplesOf10OfSet)
      // ↑ null @@ -628,7 +628,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    findLast

    Returns KoconutPrimitive<null | DataType>

    findLast

    • Returns the last element matching the given predicate, or null if no such element was found.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const lastEventNumberOfArray = await koconutArray
      .findLast(eachNumber => eachNumber % 2 == 0)
      .yield()
      console.log(lastEventNumberOfArray)
      // ↑ 4

      const lastMultiplesOf10Array = await koconutArray
      .findLast(eachNumber => eachNumber % 10 == 0)
      .yield()
      console.log(lastMultiplesOf10Array)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const lastOddNumberOfSet = await koconutSet
      .findLast(eachNumber => eachNumber % 2 == 1)
      .yield()
      console.log(lastOddNumberOfSet)
      // ↑ 5

      const lastMultiplesOf10OfSet = await koconutSet
      .findLast(eachNumber => eachNumber % 10 == 0)
      .yield()
      console.log(lastMultiplesOf10OfSet)
      // ↑ null @@ -637,7 +637,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    first

    Returns KoconutPrimitive<null | DataType>

    first

    • Returns the first element matching the given predicate. Or, if predicate is omitted method will just return the very first element of this collection. If source data is null or no element matching given predicate is found, it throws KoconutNoSuchElementException.

      @@ -650,7 +650,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<DataType>

    firstOrNull

    Returns KoconutPrimitive<DataType>

    firstOrNull

    • Returns the first element matching the given predicate. Or, if predicate is omitted method will just return the very first element of this collection. If source data is null or no element matching given predicate is found, it returns null.

      @@ -661,14 +661,14 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    indexOf

    Returns KoconutPrimitive<null | DataType>

    indexOf

    • Returns first index of element. or -1 if the collection does not contains element.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const indexOf3 = await koconutArray
      .indexOf(3)
      .yield()
      console.log(indexOf3)
      // ↑ 2

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const indexOf10 = await koconutSet
      .indexOf(10)
      .yield()
      console.log(indexOf10)
      // ↑ -1

      Parameters

      • elementToFind: DataType

        The element to search for.

        -

      Returns KoconutPrimitive<number>

    indexOfFirst

    Returns KoconutPrimitive<number>

    indexOfFirst

    • Returns index of the first element matching the given predicate, or -1 if the collection does not contain such element.

      since

      1.0.10

      @@ -678,7 +678,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<number>

    indexOfLast

    Returns KoconutPrimitive<number>

    indexOfLast

    • Returns index of the last element matching the given predicate, or -1 if the collection does not contain such element.

      since

      1.0.10

      @@ -688,7 +688,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<number>

    Transformer Methods

    associate

    Returns KoconutPrimitive<number>

    Transformer Methods

    associate

    • Returns a KoconutMap containing key-value paired Entry provided by transform function applied to elements of the given collection.

      since

      1.0.10

      @@ -698,7 +698,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    associateBy

    • associateBy<KeyType, ValueType>(keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutMap<KeyType, ValueType>

    Returns KoconutMap<KeyType, ValueType>

    associateBy

    • associateBy<KeyType, ValueType>(keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutMap<KeyType, ValueType>
    • Returns a KoconutMap containing the elements from the given collection indexed by the key returned from keySelector function applied to each element. valueTransform callback function is optional. If it's not omitted the method returns @@ -715,7 +715,7 @@

      An object to which the this keyword can refer in the keySelector. If keySelectorThisArg is omitted, null is used as the this value.

    • valueTransformThisArg: any = null

      An object to which the this keyword can refer in the valueTransform. If valueTransformThisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    associateByTo

    • associateByTo<KeyType, ValueType>(destination: Map<KeyType, ValueType>, keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutSet<DataType>

    Returns KoconutMap<KeyType, ValueType>

    associateByTo

    • associateByTo<KeyType, ValueType>(destination: Map<KeyType, ValueType>, keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutSet<DataType>
    • Populates the given destination map with entries, where key is provided by keySelector function applied to each element. valueTransform callback function is optional. If it's omitted, each value of entry @@ -735,7 +735,7 @@

      An object to which the this keyword can refer in the keySelector. If keySelectorThisArg is omitted, null is used as the this value.

    • valueTransformThisArg: any = null

      An object to which the this keyword can refer in the valueTransform. If valueTransformThisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    associateTo

    • associateTo<KeyType, ValueType>(destination: Map<KeyType, ValueType>, transform: Transformer<DataType, [KeyType, ValueType] | Pair<KeyType, ValueType> | KoconutPair<KeyType, ValueType> | Entry<KeyType, ValueType> | KoconutEntry<KeyType, ValueType>>, thisArg?: any): KoconutSet<DataType>

    Returns KoconutSet<DataType>

    associateTo

    • associateTo<KeyType, ValueType>(destination: Map<KeyType, ValueType>, transform: Transformer<DataType, [KeyType, ValueType] | Pair<KeyType, ValueType> | KoconutPair<KeyType, ValueType> | Entry<KeyType, ValueType> | KoconutEntry<KeyType, ValueType>>, thisArg?: any): KoconutSet<DataType>
    • Populates the given destination map with entries, provided by transform function applied to elements of the given collection

      note

      This method has different functionality with Kotlin. It'll return the original collection instance.

      @@ -748,7 +748,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    associateWith

    • associateWith<ValueType>(valueSelector: Selector<DataType, ValueType>, thisArg?: any): KoconutMap<DataType, ValueType>

    Returns KoconutSet<DataType>

    associateWith

    • associateWith<ValueType>(valueSelector: Selector<DataType, ValueType>, thisArg?: any): KoconutMap<DataType, ValueType>
    • Returns a KoconutMap where keys are original elements of the current object and values are produced by the valueSelector function applied to each element.

      since

      1.0.10

      @@ -758,7 +758,7 @@

      A callback function that accepts an argument. The method calls the valueSelector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the valueSelector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<DataType, ValueType>

    associateWithTo

    • associateWithTo<ValueType>(destination: Map<DataType, ValueType>, valueSelector: Selector<DataType, ValueType>, thisArg?: any): KoconutSet<DataType>

    Returns KoconutMap<DataType, ValueType>

    associateWithTo

    • associateWithTo<ValueType>(destination: Map<DataType, ValueType>, valueSelector: Selector<DataType, ValueType>, thisArg?: any): KoconutSet<DataType>
    • Populates the given destination map with entries for each element of the given collection, where key is the element itslef and value is provided by valueSelector function applied to that key.

      @@ -772,7 +772,7 @@

      A callback function that accepts an argument. The method calls the valueSelector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the valueSelector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    chunked

    • chunked<ResultDataType>(size: number, transform: null | Transformer<DataType[], ResultDataType>, thisArg: any): KoconutArray<DataType[] | ResultDataType>

    Returns KoconutSet<DataType>

    chunked

    • chunked<ResultDataType>(size: number, transform: null | Transformer<DataType[], ResultDataType>, thisArg: any): KoconutArray<DataType[] | ResultDataType>

    Returns KoconutArray<DataType[] | ResultDataType>

    flatMap

    • flatMap<ResultDataType>(transform: Transformer<DataType, Iterable<ResultDataType>>, thisArg?: any): KoconutArray<ResultDataType>

    Returns KoconutArray<DataType[] | ResultDataType>

    flatMap

    • flatMap<ResultDataType>(transform: Transformer<DataType, Iterable<ResultDataType>>, thisArg?: any): KoconutArray<ResultDataType>
    • Returns a single list of all elements yielded from results of transform function being invoked on each element of original collection.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of("123", "45")

      const allNumberInArray = await koconutArray
      .flatMap(eachString => eachString)
      // ↑ The string itself can be used as Iterable<string>.
      // If you want to make it clear, also possible to type
      // as eachString => eachString.split('')
      .map(parseInt)
      .yield()
      console.log(allNumberInArray)
      // ↑ [ 1, 2, 3, 4, 5 ]

      // Case 2 - KoconutSet
      const koconutSet = KoconutSet.of("abc", "de")

      const allCharactersInSet = await koconutSet
      .flatMap(eachString => eachString)
      .yield()
      console.log(allCharactersInSet)
      // ↑ [ 'a', 'b', 'c', 'd', 'e' ]

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associateWith(eachNumber => eachNumber * 2)

      const allKeysAndValuesInMap = await koconutMap
      .flatMap(eachEntry => [eachEntry.key, eachEntry.value])
      .yield()
      console.log(allKeysAndValuesInMap)
      // ↑ [1, 2, 2, 4, 3, 6, 4, 8, 5, 10]


      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(123, 987)

      const allDigitsInArray = await koconutArray2
      .flatMap(async eachNumber => {
      const digits = new Array<number>()
      while(eachNumber != 0) {
      digits.unshift(eachNumber % 10)
      eachNumber = Math.floor(eachNumber / 10)
      }
      return digits
      })
      .yield()
      console.log(allDigitsInArray)
      // ↑ [ 1, 2, 3, 9, 8, 7 ]

      const allNumberCharactersInArray = await koconutArray2
      .flatMap(eachNumber => new Promise<string>(resolve => {
      resolve(eachNumber.toString())
      }))
      .yield()
      console.log(allNumberCharactersInArray)
      // ↑ [ '1', '2', '3', '9', '8', '7' ] @@ -795,7 +795,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    flatMapIndexed

    Returns KoconutArray<ResultDataType>

    flatMapIndexed

    • Returns a KoconutArray of all elements yielded from results of transform function being invoked on each element of original collection.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(100, 101, 102)

      const allNumbersAndIndexOfArray = await koconutArray
      .flatMapIndexed((eachIndex, eachNumber) =>
      [eachIndex, eachNumber]
      )
      .yield()
      console.log(allNumbersAndIndexOfArray)
      // ↑ [ 0, 100, 1, 101, 2, 102 ]

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(100, 101, 102)

      const allNumbersAndIndexOfSet = await koconutSet
      .flatMapIndexed((eachIndex, eachNumber) =>
      [eachIndex, eachNumber]
      )
      .yield()
      console.log(allNumbersAndIndexOfSet)
      // ↑ [ 0, 100, 1, 101, 2, 102 ]

      // Case 3 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(123, 987)

      const allDigitsAndIndexInArray = await koconutArray2
      .flatMapIndexed(async (eachIndex, eachNumber) => {
      const digits = new Array<number>()
      while(eachNumber != 0) {
      digits.unshift(eachNumber % 10)
      eachNumber = Math.floor(eachNumber / 10)
      }
      return [eachIndex, ...digits]
      })
      .yield()
      console.log(allDigitsAndIndexInArray)
      // ↑ [
      // 0, 1, 2, 3,
      // 1, 9, 8, 7
      // ]

      const allNumberAndIndexCharactersInArray = await koconutArray2
      .flatMapIndexed((eachInex, eachNumber) => new Promise<string>(resolve => {
      resolve(`${eachInex}${eachNumber}`)
      }))
      .yield()
      console.log(allNumberAndIndexCharactersInArray)
      // ↑ [
      // '0', '1', '2',
      // '3', '1', '9',
      // '8', '7'
      // ] @@ -804,7 +804,7 @@

      A callback function that accepts two arguments. The method calls the transform one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    flatMapIndexedTo

    • flatMapIndexedTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, Iterable<ResultDataType>>, thisArg?: any): KoconutSet<DataType>

    Returns KoconutArray<ResultDataType>

    flatMapIndexedTo

    • flatMapIndexedTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, Iterable<ResultDataType>>, thisArg?: any): KoconutSet<DataType>
    • Appends all elements yielded from results of transform function being invoked on each element and its index in the original collection, to the given destination.

      since

      1.0.10

      @@ -816,7 +816,7 @@

      A callback function that accepts two arguments. The method calls the transform one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    flatMapTo

    • flatMapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, Iterable<ResultDataType>>, thisArg?: any): KoconutSet<DataType>

    Returns KoconutSet<DataType>

    flatMapTo

    • flatMapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, Iterable<ResultDataType>>, thisArg?: any): KoconutSet<DataType>
    • Appends all elements yielded from results of transform function being invoked on each element of original collection, to the given destination.

      since

      1.0.10

      @@ -828,7 +828,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    groupBy

    • groupBy<KeyType, ValueType>(keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutMap<KeyType, ValueType[]>

    Returns KoconutSet<DataType>

    groupBy

    • groupBy<KeyType, ValueType>(keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutMap<KeyType, ValueType[]>
    • Groups values returned by the valueTransform function applied to each element of the original collection by the key returned by the given keySelector function applied to the element and returns a map where each group key is associated with a list of corresponding values. If valueTransform is omitted, the value of @@ -844,7 +844,7 @@

      An object to which the this keyword can refer in the keySelector. If keySelectorThisArg is omitted, null is used as the this value.

    • valueTransformThisArg: any = null

      An object to which the this keyword can refer in the valueTransform. If valueTransformThisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType[]>

    groupByTo

    • groupByTo<KeyType, ValueType>(destination: Map<KeyType, ValueType[]>, keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutSet<DataType>

    Returns KoconutMap<KeyType, ValueType[]>

    groupByTo

    • groupByTo<KeyType, ValueType>(destination: Map<KeyType, ValueType[]>, keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutSet<DataType>
    • Groups values returned by the valueTransform function applied to each element of the original collection by the key returned by the given keySelector function applied to the element and puts to the destination map each group key associated with a list of corresponding values. If valueTransform is omitted, each value would be original element.

      @@ -861,7 +861,7 @@

      An object to which the this keyword can refer in the keySelector. If keySelectorThisArg is omitted, null is used as the this value.

    • valueTransformThisArg: any = null

      An object to which the this keyword can refer in the valueTransform. If valueTransformThisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    map

    Returns KoconutSet<DataType>

    map

    • Returns a list containing the results of applying the given transform function to each element in the original collection.

      since

      1.0.10

      @@ -871,7 +871,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    mapIndexed

    Returns KoconutArray<ResultDataType>

    mapIndexed

    • Returns a list of all elements yielded from results of transform function being invoked on each element and its index in the original collection.

      since

      1.0.10

      @@ -881,7 +881,7 @@

      A callback function that accepts two arguments. The method calls the transform one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    mapIndexedNotNull

    • mapIndexedNotNull<ResultDataType>(transform: IndexedTransformer<DataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    Returns KoconutArray<ResultDataType>

    mapIndexedNotNull

    • mapIndexedNotNull<ResultDataType>(transform: IndexedTransformer<DataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>
    • Returns a KoconutArray containing only the results that are not null nor undefined of applying the given transform function to each element and its index in the original collection.

      since

      1.0.10

      @@ -891,7 +891,7 @@

      A callback function that accepts two arguments. The method calls the transform one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    mapIndexedNotNullTo

    • mapIndexedNotNullTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutSet<DataType>

    Returns KoconutArray<ResultDataType>

    mapIndexedNotNullTo

    • mapIndexedNotNullTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutSet<DataType>
    • Applies the given transform function to each element and its index in the original collection and appends the results that are not null nor undefined to the given destination.

      since

      1.0.10

      @@ -903,7 +903,7 @@

      A callback function that accepts two arguments. The method calls the transform one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    mapIndexedTo

    • mapIndexedTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, ResultDataType>, thisArg?: any): KoconutSet<DataType>

    Returns KoconutSet<DataType>

    mapIndexedTo

    • mapIndexedTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, ResultDataType>, thisArg?: any): KoconutSet<DataType>
    • Applies the given transform function to each element and its index in the original collection and appends the results to the given destination.

      since

      1.0.10

      @@ -915,7 +915,7 @@

      A callback function that accepts two arguments. The method calls the transform one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    mapNotNull

    • mapNotNull<ResultDataType>(transform: Transformer<DataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    Returns KoconutSet<DataType>

    mapNotNull

    • mapNotNull<ResultDataType>(transform: Transformer<DataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>
    • Returns a list containing results that are not null nor undefined of applying the given transfrom function to each element in the original collection. You can use this method as filter then map.

      since

      1.0.10

      @@ -925,7 +925,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    mapNotNullTo

    • mapNotNullTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, ResultDataType>, thisArg?: any): KoconutSet<DataType>

    Returns KoconutArray<ResultDataType>

    mapNotNullTo

    • mapNotNullTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, ResultDataType>, thisArg?: any): KoconutSet<DataType>
    • Applies the given transform function to each element of the original collection and appends only the results that are not null nor undefined.

      since

      1.0.10

      @@ -937,7 +937,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutSet<DataType>

    mapTo

    • mapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, ResultDataType>, thisArg?: any): KoconutSet<DataType>

    Returns KoconutSet<DataType>

    mapTo

    • mapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, ResultDataType>, thisArg?: any): KoconutSet<DataType>
    • Applies the given transform function to each element of the original collection and appends the results to the given destination.

      since

      1.0.10

      diff --git a/docs/classes/Pair.html b/docs/classes/Pair.html index 784746a..d3015c9 100644 --- a/docs/classes/Pair.html +++ b/docs/classes/Pair.html @@ -15,19 +15,19 @@

      The type of the first value.

    • SecondType

      The type of the second value.

      -

    Hierarchy

    • Pair

    Implements

    Index

    Constructors

    constructor

    • new Pair<FirstType, SecondType>(firstElement: FirstType, secondElement: SecondType): Pair<FirstType, SecondType>

    Hierarchy

    • Pair

    Implements

    Index

    Constructors

    constructor

    • new Pair<FirstType, SecondType>(firstElement: FirstType, secondElement: SecondType): Pair<FirstType, SecondType>

    Accessors

    first

    • get first(): FirstType

    Returns Pair<FirstType, SecondType>

    Accessors

    first

    • get first(): FirstType

    second

    • get second(): SecondType

    second

    • get second(): SecondType

    Methods

    equalsTo

    Methods

    equalsTo

    • Class Pair implements KoconutEquatable. The 'equalsTo' method of this basically check whether each individual element (first/second) is same or not. When the type of each element is child of KoconutEquatable, it'd be done by using its 'equalsTo' method. @@ -35,19 +35,19 @@

      example
        // Case 1 -- All values are simply number or string
      const myPairCase1_01 = Pair.from([10, 20])
      const myPairCase1_02 = Pair.from([10, 20])
      console.log(`${myPairCase1_01.equalsTo(myPairCase1_02)}`)
      // ↑ true

      const myPairCase1_03 = Pair.from(["Apex", "Captain"])
      const myPairCase1_04 = Pair.from(["Apex", "Captain"])
      console.log(`${myPairCase1_03 == myPairCase1_04}`)
      // ↑ false
      console.log(`${myPairCase1_03.equalsTo(myPairCase1_04)}`)
      // ↑ true

      // Case 2 -- First Type is indistinguishable class
      class MyClass {
      private value : string
      constructor(value : string) {
      this.value = value
      }
      }
      const myPairCase2_01 = Pair.from([new MyClass("Apex"), "Captain"])
      const myPairCase2_02 = Pair.from([new MyClass("Apex"), "Captain"])
      console.log(`${myPairCase2_01.equalsTo(myPairCase2_02)}`)
      // ↑ false

      // Case 3 -- First Type is distinguishable class
      class MyDistinguishableClass implements KoconutEquatable {
      private value : string
      constructor(value : string) {
      this.value = value
      }
      equalsTo(other : MyDistinguishableClass) : boolean {
      return this.value == other.value
      }
      }
      const myPairCase3_01 = Pair.from([new MyDistinguishableClass("Apex"), "Captain"])
      const myPairCase3_02 = Pair.from([new MyDistinguishableClass("Apex"), "Captain"])
      console.log(`${myPairCase3_01.equalsTo(myPairCase3_02)}`)
      // ↑ true

      Parameters

      • other: Pair<FirstType, SecondType>
        -

      Returns boolean | KoconutBoolean

    toArray

    • toArray(): [FirstType, SecondType]

    Returns boolean | KoconutBoolean

    toArray

    • toArray(): [FirstType, SecondType]
    • Turns this Pair instance into a simple array.

      example
      const myPair = Pair.from(["Apex","Captain"])
      console.log(myPair.toArray())
      // ↑ [ 'Apex', 'Captain' ]
      -

      Returns [FirstType, SecondType]

    toEntry

    • toEntry(): Entry<FirstType, SecondType>

    toEntry

    • toEntry(): Entry<FirstType, SecondType>

    toString

    • toString(): string

    toString

    • toString(): string
    • Turns this Pair instance into a simple JSON object string.

      example
      const myPair = Pair.from(["Apex","Captain"])
      console.log(myPair.toString()) // Or, you can use console.log(`${myPair}`)
      // ↑ {"first":"Apex","second":"Captain"}
      -

      Returns string

    Static from

    • from<FirstType, SecondType>(pair: [FirstType, SecondType]): Pair<FirstType, SecondType>

    Static from

    • from<FirstType, SecondType>(pair: [FirstType, SecondType]): Pair<FirstType, SecondType>

    foldIndexed

    • foldIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutPrimitive<ResultDataType>

    Returns KoconutPrimitive<ResultDataType>

    foldIndexed

    • foldIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutPrimitive<ResultDataType>
    • Accumulates value starting with initial value and applying operation from left to right to current accumulator value and each element.

      since

      1.0.10

      @@ -24,7 +24,7 @@ previously returned in the last invocation of the callback or initial value. The method calls the operation one time for each element and index in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the operation. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<ResultDataType>

    Calculator Methods

    count

    Returns KoconutPrimitive<ResultDataType>

    Calculator Methods

    count

    • Returns the number of the elements matching the given predicate. If the predicate is ommitted it'll returns the whole number of elements.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const numberOfAllArrayElements = await koconutArray
      .count()
      .yield()
      console.log(numberOfAllArrayElements)
      // ↑ 5

      const numberOfArrayElementsHigherThan2 = await koconutArray
      .count(eachNumber => eachNumber > 2)
      .yield()
      console.log(numberOfArrayElementsHigherThan2)
      // ↑ 3 -- i.e. [3, 4, 5]

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const numberOfAllSetElements = await koconutSet
      .count()
      .yield()
      console.log(numberOfAllSetElements)
      // ↑ 5

      const numberOfOddSetElements = await koconutSet
      .count(eachNumber => eachNumber % 2 == 1)
      .yield()
      console.log(numberOfOddSetElements)
      // ↑ 3 -- i.e. [1, 3, 5]

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3)
      .associateWith(eachNumber => eachNumber * 2)
      // ↑ Map { 1 => 2,
      // 2 => 4,
      // 3 => 6 }

      const numberOfAllMapEntries = await koconutMap
      .count()
      .yield()
      console.log(numberOfAllMapEntries)
      // ↑ 3

      const numberOfMapEntriesValueHigherThan5 = await koconutMap
      .count(eachEntry => eachEntry.value > 5)
      .yield()
      console.log(numberOfMapEntriesValueHigherThan5)
      // ↑ 1 -- i.e. Entry { 3, 6 }

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(1,2,3,4,5)

      const numberOfArrayElementsLessThan3 = await koconutArray2
      .count(async eachNumber => eachNumber < 3)
      .yield()
      console.log(numberOfArrayElementsLessThan3)
      // ↑ 2 -- i.e. [1, 2]

      const numberOfEvenArrayElements = await koconutArray2
      .count(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 2 == 0)
      }))
      .yield()
      console.log(numberOfEvenArrayElements)
      // ↑ 2 -- i.e. [2, 4] @@ -33,7 +33,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<number>

    maxBy

    Returns KoconutPrimitive<number>

    maxBy

    Returns KoconutPrimitive<DataType>

    maxByOrNull

    Returns KoconutPrimitive<DataType>

    maxByOrNull

    • Returns the first element yielding the largest value of the given function or null if there are no elements.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const largestNumberOfArray = await koconutArray
      .maxByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(largestNumberOfArray)
      // ↑ 5


      const largestNumberOfEmptyArray = await koconutArray
      .filter(eachNumber => eachNumber > 10)
      .maxByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(largestNumberOfEmptyArray)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of("a", "ab", "abc")

      const longestStringOfSet = await koconutSet
      .maxByOrNull(eachString => eachString.length)
      .yield()
      console.log(longestStringOfSet)
      // ↑ abc

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1, 12, 123)
      .associateWith(eachNumber => eachNumber.toString())

      const longestDigitsEntryOfMap = await koconutMap
      .maxByOrNull(eachEntry => eachEntry.value.length)
      .yield()
      console.log(longestDigitsEntryOfMap)
      // ↑ Entry { keyElement: 123, valueElement: '123' }

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(19,27,32)

      const largestNumberOfArray2 = await koconutArray2
      .maxByOrNull(async eachNumber => eachNumber)
      .yield()
      console.log(largestNumberOfArray2)
      // ↑ 32

      const largest1sDigitNumberOfArray2 = await koconutArray2
      .maxByOrNull(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 10)
      }))
      .yield()
      console.log(largest1sDigitNumberOfArray2)
      // ↑ 19 @@ -54,7 +54,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    maxOf

    • maxOf<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutPrimitive<null | DataType>

    maxOf

    • maxOf<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    maxOfOrNull

    • maxOfOrNull<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    maxOfOrNull

    • maxOfOrNull<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>
    • Returns the largest value among all values produced by selector function applied to each element in the collection or null if there are no elements.

      since

      1.0.10

      @@ -75,7 +75,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | string | number | ComparableType>

    maxOfWith

    • maxOfWith<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>

    Returns KoconutPrimitive<null | string | number | ComparableType>

    maxOfWith

    • maxOfWith<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>
    • Returns the largest value according to the provided comparator among all values produced by selector function applied to each element in the collection all throws KoconutNoSuchElementException if elements are empty.

      @@ -92,7 +92,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<ResultDataType>

    maxOfWithOrNull

    • maxOfWithOrNull<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>

    Returns KoconutPrimitive<ResultDataType>

    maxOfWithOrNull

    • maxOfWithOrNull<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>
    • Returns the largest value according to the provided comparator among all values produced by selector function applied to each element in the collection or null if elements are empty.

      @@ -108,7 +108,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | ResultDataType>

    maxWith

    Returns KoconutPrimitive<null | ResultDataType>

    maxWith

    Returns KoconutPrimitive<DataType>

    maxWithOrNull

    Returns KoconutPrimitive<DataType>

    maxWithOrNull

    • Returns the first element having the largest value according to the provided comparator or null if elements are empty.

      since

      1.0.10

      @@ -131,7 +131,7 @@ In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.

    • thisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    minBy

    Returns KoconutPrimitive<null | DataType>

    minBy

    Returns KoconutPrimitive<DataType>

    minByOrNull

    Returns KoconutPrimitive<DataType>

    minByOrNull

    • Returns the first element yielding the smallest value of the given function or null if there are no elements.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const smallestNumberOfArray = await koconutArray
      .minByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(smallestNumberOfArray)
      // ↑ 1

      const smallestNumberOfEmptyArray = await koconutArray
      .filter(eachNumber => eachNumber > 10)
      .minByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(smallestNumberOfEmptyArray)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of("a", "ab", "abc")

      const shortestStringOfSet = await koconutSet
      .minByOrNull(eachString => eachString.length)
      .yield()
      console.log(shortestStringOfSet)
      // ↑ a

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1, 12, 123)
      .associateWith(eachNumber => eachNumber.toString())

      const shortestDigitsEntryOfMap = await koconutMap
      .minByOrNull(eachEntry => eachEntry.value.length)
      .yield()
      console.log(shortestDigitsEntryOfMap)
      // ↑ Entry { keyElement: 1, valueElement: '1' }

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(19,27,32)

      const smallestNumberOfArray2 = await koconutArray2
      .minByOrNull(async eachNumber => eachNumber)
      .yield()
      console.log(smallestNumberOfArray2)
      // ↑ 19

      const smallest1sDigitNumberOfArray2 = await koconutArray2
      .minByOrNull(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 10)
      }))
      .yield()
      console.log(smallest1sDigitNumberOfArray2)
      // ↑ 32 @@ -152,7 +152,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    minOf

    • minOf<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutPrimitive<null | DataType>

    minOf

    • minOf<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    minOfOrNull

    • minOfOrNull<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    minOfOrNull

    • minOfOrNull<ComparableType>(selector: Selector<DataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>
    • Returns the smallest value among all values produced by selector function applied to each element in the collection or null if there are no elements.

      since

      1.0.10

      @@ -173,7 +173,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | string | number | ComparableType>

    minOfWith

    • minOfWith<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>

    Returns KoconutPrimitive<null | string | number | ComparableType>

    minOfWith

    • minOfWith<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>
    • Returns the smallest value according to the provided comparator among all values produced by selector function applied to each element in the collection all throws KoconutNoSuchElementException if elements are empty.

      @@ -190,7 +190,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<ResultDataType>

    minOfWithOrNull

    • minOfWithOrNull<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>

    Returns KoconutPrimitive<ResultDataType>

    minOfWithOrNull

    • minOfWithOrNull<ResultDataType>(selector: Selector<DataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>
    • Returns the smallest value according to the provided comparator among all values produced by selector function applied to each element in the collection all null if elements are empty.

      @@ -207,7 +207,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | ResultDataType>

    minWith

    Returns KoconutPrimitive<null | ResultDataType>

    minWith

    Returns KoconutPrimitive<DataType>

    minWithOrNull

    Returns KoconutPrimitive<DataType>

    minWithOrNull

    • Returns the first element having the smallest value according to the provided comparator or null if elements are empty.

      since

      1.0.10

      @@ -230,17 +230,17 @@ In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.

    • thisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    Caster Methods

    asArray

    Returns KoconutPrimitive<null | DataType>

    Caster Methods

    asArray

    • Creates an KoconutArray instance that wraps original data.

      since

      1.0.13

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const arrToArr = await koconutArray
      .asArray()
      .yield()
      console.log(arrToArr)
      // ↑ [ 1, 2, 3, 4, 5 ]

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,1,2,2,3,3,4,4,5,5)

      const setToArr = await koconutSet
      .asArray()
      .yield()
      console.log(setToArr)
      // ↑ [ 1, 2, 3, 4, 5 ]

      // Case 3 -- KoconutFlow
      const koconutFlow = KoconutFlow.ofSimple(1,2,3,4,5)

      const flowToArr = await koconutFlow
      .asArray()
      .yield()
      console.log(flowToArr)
      // ↑
      // [
      // Entry { keyElement: 0, valueElement: 1 },
      // Entry { keyElement: 1, valueElement: 2 },
      // Entry { keyElement: 2, valueElement: 3 },
      // Entry { keyElement: 3, valueElement: 4 },
      // Entry { keyElement: 4, valueElement: 5 }
      // ]

      // Case 4 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber])

      const mapToArr = await koconutMap
      .asArray()
      .yield()
      console.log(mapToArr)
      // ↑
      // [
      // Entry { keyElement: 1, valueElement: 1 },
      // Entry { keyElement: 2, valueElement: 2 },
      // Entry { keyElement: 3, valueElement: 3 },
      // Entry { keyElement: 4, valueElement: 4 },
      // Entry { keyElement: 5, valueElement: 5 }
      // ]
      -

      Returns KoconutArray<DataType>

    asSet

    asSet

    • Creates an KoconutSet instance that wraps original data.

      since

      1.0.13

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const arrToSet = await koconutArray
      .asSet()
      .yield()
      console.log(arrToSet)
      // ↑ Set { 1, 2, 3, 4, 5 }

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,1,2,2,3,3,4,4,5,5)

      const setToSet = await koconutSet
      .asSet()
      .yield()
      console.log(setToSet)
      // ↑ Set { 1, 2, 3, 4, 5 }

      // Case 3 -- KoconutFlow
      const koconutFlow = KoconutFlow.ofSimple(1,2,3,4,5)

      const flowToSet = await koconutFlow
      .asSet()
      .yield()
      console.log(flowToSet)
      // ↑
      // Set {
      // Entry { keyElement: 0, valueElement: 1 },
      // Entry { keyElement: 1, valueElement: 2 },
      // Entry { keyElement: 2, valueElement: 3 },
      // Entry { keyElement: 3, valueElement: 4 },
      // Entry { keyElement: 4, valueElement: 5 }
      // }

      // Case 4 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber])

      const mapToSet = await koconutMap
      .asSet()
      .yield()
      console.log(mapToSet)
      // ↑
      // Set {
      // Entry { keyElement: 1, valueElement: 1 },
      // Entry { keyElement: 2, valueElement: 2 },
      // Entry { keyElement: 3, valueElement: 3 },
      // Entry { keyElement: 4, valueElement: 4 },
      // Entry { keyElement: 5, valueElement: 5 }
      // }
      -

      Returns KoconutSet<DataType>

    Inspector Methods

    all

    Inspector Methods

    all

    • Return true if all elements match te given predicate.

      since

      1.0.10

      example
        // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const areAllArrayElementsGreaterThan0 = await koconutArray
      .all(eachNumber => eachNumber > 0)
      .yield()
      console.log(areAllArrayElementsGreaterThan0)
      // ↑ true

      const areAllArrayElementsEven = await koconutArray
      .all(eachNumber => eachNumber % 2 == 0)
      .yield()
      console.log(areAllArrayElementsEven)
      // ↑ false -- i.e. '1' is not an even number.


      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const areAllSetElementsGreaterThan0 = await koconutSet
      .all(eachNumber => eachNumber > 0)
      .yield()
      console.log(areAllSetElementsGreaterThan0)
      // ↑ true

      const areAllSetElementsOdd = await koconutSet
      .all(eachNumber => eachNumber % 2 == 1)
      .yield()
      console.log(areAllSetElementsOdd)
      // ↑ false -- i.e. '2' is not an odd number.


      // Case 3 -- KoconutMap
      const koconutMap = KoconutMap.of(
      [0, 0],
      [1, 1],
      [2, 2]
      )

      const areAllMapEntriesKeyEqualsToValue = await koconutMap
      .all(eachEntry => eachEntry.key == eachEntry.value)
      .yield()
      console.log(areAllMapEntriesKeyEqualsToValue)
      // ↑ true

      const areAllMapEntriesSumGreaterThan3 = await koconutMap
      .all(eachEntry => eachEntry.key + eachEntry.value > 3)
      .yield()
      console.log(areAllMapEntriesSumGreaterThan3)
      // ↑ false -- i.e. Sum of key and value of first Entry { 0, 0 } is 0.
      // It's definetly less than 3

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(1,2,3,4,5)

      const areAllArrayElementsLessThan10 = await koconutArray2
      .all(async eachNumber => eachNumber < 10)
      .yield()
      console.log(areAllArrayElementsLessThan10)
      // ↑ true

      const areAllArrayElementsOdd = await koconutArray2
      .all(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 2 == 1)
      }))
      .yield()
      console.log(areAllArrayElementsOdd)
      // ↑ false -- i.e. '2' is not an odd number. @@ -249,7 +249,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutBoolean

    any

    Returns KoconutBoolean

    any

    • Returns true if the collection has at least one element matches the given predicate.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isAnyArrayElementGreaterThan4 = await koconutArray
      .any(eachNumber => eachNumber > 4)
      .yield()
      console.log(isAnyArrayElementGreaterThan4)
      // ↑ true -- i.e. '5' is greater than 4.

      const isAnyArrayElementMultipleOf6 = await koconutArray
      .any(eachNumber => eachNumber % 6 == 0)
      .yield()
      console.log(isAnyArrayElementMultipleOf6)
      // ↑ false

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isAnySetElementGreaterThan3 = await koconutSet
      .any(eachNumber => eachNumber > 3)
      .yield()
      console.log(isAnySetElementGreaterThan3)
      // ↑ true -- i.e. '4' is greater than 3.

      const isAnySetElementLessThan0 = await koconutSet
      .any(eachNumber => eachNumber < 0)
      .yield()
      console.log(isAnySetElementLessThan0)
      // ↑ false

      // Case 3 -- KoconutMap
      const koconutMap = KoconutMap.of(
      [0, 0],
      [1, 1],
      [2, 2]
      )

      const isAnyMapEntrySumGreaterThan3 = await koconutMap
      .any(eachEntry => eachEntry.key + eachEntry.value > 3)
      .yield()
      console.log(isAnyMapEntrySumGreaterThan3)
      // ↑ true -- i.e. Sum of key and value of third Entry { 2, 2 } is 4.
      // It's grater than 4.

      const isAnyMapEntryKeyMultipleOf4 = await koconutMap
      .any(eachEntry => eachEntry.key > 0 && eachEntry.key % 4 == 0)
      .yield()
      console.log(isAnyMapEntryKeyMultipleOf4)
      // ↑ false

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(1,2,3,4,5)

      const isAnyArrayElementLessThan2 = await koconutArray2
      .any(async eachNumber => eachNumber < 2)
      .yield()
      console.log(isAnyArrayElementLessThan2)
      // ↑ true -- i.e. '1' is less than 2.

      const isAnyArrayElementGreaterThan7 = await koconutArray2
      .any(eachNumber => new Promise(resolve => {
      resolve(eachNumber > 7)
      }))
      .yield()
      console.log(isAnyArrayElementGreaterThan7)
      // ↑ false @@ -258,38 +258,38 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutBoolean

    contains

    Returns KoconutBoolean

    contains

    • Checks if the specified element is contained in this collection.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const doesArrayContain3 = await koconutArray
      .contains(3)
      .yield()
      console.log(doesArrayContain3)
      // ↑ true

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const doesSetContains6 = await koconutSet
      .contains(6)
      .yield()
      console.log(doesSetContains6)
      // ↑ false

      Parameters

      • element: DataType

        The element to search for.

        -

      Returns KoconutBoolean

    containsAll

    Returns KoconutBoolean

    containsAll

    • Checks if all the elements are contained in this collection.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const doesArrayContain1to3 = await koconutArray
      .containsAll([1,2,3])
      .yield()
      console.log(doesArrayContain1to3)
      // ↑ true

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const doesSetContains5to6 = await koconutSet
      .containsAll([5,6,7])
      .yield()
      console.log(doesSetContains5to6)
      // ↑ false

      Parameters

      • elements: Iterable<DataType>

        The elements to search for.

        -

      Returns KoconutBoolean

    isEmpty

    Returns KoconutBoolean

    isEmpty

    • Returns true if the collection is empty (contains no elements), false otherwise.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isNumberArrayEmpty = await koconutArray
      .isEmpty()
      .yield()
      console.log(isNumberArrayEmpty)
      // ↑ false

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isFilteredNumberSetEmpty = await koconutSet
      .filter(eachNumber => eachNumber > 10)
      .isEmpty()
      .yield()
      console.log(isFilteredNumberSetEmpty)
      // ↑ true

      // Case 3 -- KoconutMap
      const koconutMap = new KoconutMap<number, number>()

      const isNumberPairedMapEmpty = await koconutMap
      .isEmpty()
      .yield()
      console.log(isNumberPairedMapEmpty)
      // ↑ true
      -

      Returns KoconutBoolean

    isNotEmpty

    isNotEmpty

    • Returns true if the collection is not empty.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isNumberArrayEmpty = await koconutArray
      .isNotEmpty()
      .yield()
      console.log(isNumberArrayEmpty)
      // ↑ true

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isFilteredNumberSetEmpty = await koconutSet
      .filter(eachNumber => eachNumber > 10)
      .isNotEmpty()
      .yield()
      console.log(isFilteredNumberSetEmpty)
      // ↑ false

      // Case 3 -- KoconutMap
      const koconutMap = new KoconutMap<number, number>()

      const isNumberPairedMapEmpty = await koconutMap
      .isNotEmpty()
      .yield()
      console.log(isNumberPairedMapEmpty)
      // ↑ false
      -

      Returns KoconutBoolean

    isNullOrEmpty

    isNullOrEmpty

    • Returns true if this nullable collection is either null or empty.

      since

      1.0.10

      deprecated

      Use isEmpty instead.

      until

      1.3.0

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isNumberArrayEmpty = await koconutArray
      .isNullOrEmpty()
      .yield()
      console.log(isNumberArrayEmpty)
      // ↑ false

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isFilteredNumberSetEmpty = await koconutSet
      .filter(eachNumber => eachNumber > 10)
      .isNullOrEmpty()
      .yield()
      console.log(isFilteredNumberSetEmpty)
      // ↑ true

      // Case 3 -- KoconutMap
      const koconutMap = new KoconutMap<number, number>()

      const isNumberPairedMapEmpty = await koconutMap
      .isNullOrEmpty()
      .yield()
      console.log(isNumberPairedMapEmpty)
      // ↑ true
      -

      Returns KoconutBoolean

    none

    none

    • predicate callback function is optional. If it's omitted the method returns true if the collection has no elements. Otherwise, returns true if no elements match the given predicate.

      since

      1.0.10

      @@ -299,7 +299,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutBoolean

    Iterator Methods

    forEach

    Returns KoconutBoolean

    Iterator Methods

    forEach

    • Performs the given action on each element. When you want to stop iteration in the meantime return false or KoconutLoopSignal.BREAK.

      since

      1.0.10

      @@ -309,7 +309,7 @@

      A callback function that accepts an argument. The method calls the action one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the action. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<void>

    forEachIndexed

    Returns KoconutPrimitive<void>

    forEachIndexed

    • Performs the given action on each element, providing sequential index with the element. When you want to stop iteration in the meantime return false or KoconutLoopSignal.BREAK.

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5,6,7)

      await koconutArray
      .forEachIndexed(console.log)
      // ↑ 0 1
      // 1 2
      // 2 3
      // 3 4
      // 4 5
      // 5 6
      // 6 7
      .process()

      await koconutArray
      .forEachIndexed((eachIndex, eachNumber) => {
      if(eachIndex == 3) return KoconutLoopSignal.BREAK
      console.log(eachNumber)
      })
      // ↑ 1 2 3 -- i.e. Since when the index is '3', the loop is interrupted.
      // The last printed number(element) would be '3'.
      .process()

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,1,2,3)

      await koconutSet
      .forEachIndexed(console.log)
      // ↑ 0 1
      // 1 2
      // 2 3
      .process()

      await koconutSet
      .forEachIndexed((eachIndex, eachNumber) => {
      if(eachIndex != 0 && eachIndex % 2 == 0) return false
      console.log(eachNumber)
      })
      // ↑ 1 2 -- i.e. Since when the index '2', it's an even number.
      // So the loop is interrupted.
      // The last printed number(element) would be '2'
      .process()

      // Case 3 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(1,2,3)

      await koconutArray2
      .forEachIndexed(async (eachIndex, eachNumber) =>
      console.log(eachIndex, eachNumber))
      // ↑ 0 1
      // 1 2
      // 2 3
      .process()

      await koconutArray2
      .forEachIndexed(async (eachIndex, eachNumber) => new Promise(resolve => {
      resolve(console.log(eachIndex, eachNumber))
      }))
      // ↑ 0 1
      // 1 2
      // 2 3
      .process() @@ -318,7 +318,7 @@

      A callback function that accepts two arguments. The method calls the action one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the action. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<void>

    Other Methods

    associateByTo

    • associateByTo<KeyType, ValueType>(destination: Map<KeyType, ValueType>, keySelector: Selector<DataType, KeyType>, valueTransform: null | Transformer<DataType, ValueType>, keySelectorThisArg: any, valueTransformThisArg: any): KoconutCollection<DataType, WrapperType>

    associateTo

    • associateTo<KeyType, ValueType>(destination: Map<KeyType, ValueType>, transform: Transformer<DataType, [KeyType, ValueType] | Pair<KeyType, ValueType> | KoconutPair<KeyType, ValueType> | Entry<KeyType, ValueType> | KoconutEntry<KeyType, ValueType>>, thisArg: any): KoconutCollection<DataType, WrapperType>

    associateWithTo

    • associateWithTo<ValueType>(destination: Map<DataType, ValueType>, valueSelector: Selector<DataType, ValueType>, thisArg: any): KoconutCollection<DataType, WrapperType>

    distinct

    distinctBy

    • distinctBy<KeyType, EquatableKeyType>(selector: Selector<DataType, KeyType | EquatableKeyType>, thisArg: any): KoconutCollection<DataType, WrapperType>

    drop

    dropLast

    dropLastWhile

    dropWhile

    filter

    filterIndexed

    filterIndexedTo

    filterNot

    filterNotNull

    filterNotNullTo

    • filterNotNullTo(destination: DataType[] | Set<DataType>): KoconutCollection<DataType, WrapperType>

    filterNotTo

    • filterNotTo(destination: DataType[] | Set<DataType>, predicate: Predicator<DataType>, thisArg: any): KoconutCollection<DataType, WrapperType>

    filterTo

    • filterTo(destination: DataType[] | Set<DataType>, predicate: Predicator<DataType>, thisArg: any): KoconutCollection<DataType, WrapperType>

    flatMapIndexedTo

    • flatMapIndexedTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, Iterable<ResultDataType>>, thisArg: any): KoconutCollection<DataType, WrapperType>

    flatMapTo

    • flatMapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, Iterable<ResultDataType>>, thisArg: any): KoconutCollection<DataType, WrapperType>

    groupByTo

    • groupByTo<KeyType, ValueType>(destination: Map<KeyType, ValueType[]>, keySelector: Selector<DataType, KeyType>, valueTransform: null | Transformer<DataType, ValueType>, keySelectorThisArg: any, valueTransformThisArg: any): KoconutCollection<DataType, WrapperType>

    indices

    intersect

    • intersect(other: Iterable<DataType>): KoconutSet<DataType>

    join

    • join(separator?: string, prefix?: string, postfix?: string, limit?: number, truncated?: string, transform?: null | Transformer<DataType, any>, thisArg?: any): KoconutPrimitive<string>

    last

    lastIndexOf

    lastOrNull

    mapIndexedNotNullTo

    • mapIndexedNotNullTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, undefined | null | void | ResultDataType>, thisArg: any): KoconutCollection<DataType, WrapperType>

    mapIndexedTo

    • mapIndexedTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, ResultDataType>, thisArg: any): KoconutCollection<DataType, WrapperType>

    mapNotNullTo

    • mapNotNullTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, undefined | null | void | ResultDataType>, thisArg: any): KoconutCollection<DataType, WrapperType>

    mapTo

    • mapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, ResultDataType>, thisArg: any): KoconutCollection<DataType, WrapperType>

    minus

    • minus(elements: DataType | Iterable<DataType>): KoconutCollection<DataType, WrapperType>

    minusElement

    onEach

    onEachIndexed

    partition

    plus

    • plus(elements: DataType | Iterable<DataType>): KoconutCollection<DataType, WrapperType>

    plusElement

    random

    randomOrNull

    reduce

    reduceIndexed

    reduceIndexedOrNull

    reduceOrNull

    retrieve

    reversed

    runningFold

    • runningFold<ResultDataType>(initial: ResultDataType, operation: Operator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    runningFoldIndexed

    • runningFoldIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    runningReduce

    runningReduceIndexed

    scan

    • scan<ResultDataType>(initial: ResultDataType, operation: Operator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    scanIndexed

    • scanIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    shuffled

    single

    singleOrNull

    size

    sortedBy

    sortedByDescending

    sortedWith

    subtract

    • subtract(other: Iterable<DataType>): KoconutSet<DataType>

    sumBy

    take

    takeLast

    takeLastWhile

    takeWhile

    union

    • union(other: Iterable<DataType>): KoconutSet<DataType>

    validate

    • validate(data: null | WrapperType): Promise<void>

    windowed

    • windowed<ResultDataType>(size: number, step: number, partialWindows: boolean, transform: null | Transformer<DataType[], ResultDataType>, thisArg: any): KoconutArray<DataType[] | ResultDataType>

    withIndex

    zip

    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: null | Zipper<DataType, OtherDataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType | Pair<DataType, OtherDataType>>
    • zip<OtherDataType>(other: Iterable<OtherDataType>): KoconutArray<Pair<DataType, OtherDataType>>
    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: Zipper<DataType, OtherDataType, ResultDataType>): KoconutArray<ResultDataType>
    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: Zipper<DataType, OtherDataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType>

    zipWithNext

    • zipWithNext<ResultDataType>(transform: null | Zipper<DataType, DataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType | Pair<DataType, DataType>>
    • zipWithNext(): KoconutArray<Pair<DataType, DataType>>
    • zipWithNext<ResultDataType>(transform: Zipper<DataType, DataType, ResultDataType>): KoconutArray<ResultDataType>
    • zipWithNext<ResultDataType>(transform: Zipper<DataType, DataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType>

    Processor Methods

    also

    • also(block: Processor<WrapperType>): Promise<null | WrapperType>

    Returns KoconutPrimitive<void>

    Other Methods

    associateByTo

    • associateByTo<KeyType, ValueType>(destination: Map<KeyType, ValueType>, keySelector: Selector<DataType, KeyType>, valueTransform: null | Transformer<DataType, ValueType>, keySelectorThisArg: any, valueTransformThisArg: any): KoconutCollection<DataType, WrapperType>

    associateTo

    • associateTo<KeyType, ValueType>(destination: Map<KeyType, ValueType>, transform: Transformer<DataType, [KeyType, ValueType] | Pair<KeyType, ValueType> | KoconutPair<KeyType, ValueType> | Entry<KeyType, ValueType> | KoconutEntry<KeyType, ValueType>>, thisArg: any): KoconutCollection<DataType, WrapperType>

    associateWithTo

    • associateWithTo<ValueType>(destination: Map<DataType, ValueType>, valueSelector: Selector<DataType, ValueType>, thisArg: any): KoconutCollection<DataType, WrapperType>

    distinct

    distinctBy

    • distinctBy<KeyType, EquatableKeyType>(selector: Selector<DataType, KeyType | EquatableKeyType>, thisArg: any): KoconutCollection<DataType, WrapperType>

    drop

    dropLast

    dropLastWhile

    dropWhile

    filter

    filterIndexed

    filterIndexedTo

    filterNot

    filterNotNull

    filterNotNullTo

    • filterNotNullTo(destination: DataType[] | Set<DataType>): KoconutCollection<DataType, WrapperType>

    filterNotTo

    • filterNotTo(destination: DataType[] | Set<DataType>, predicate: Predicator<DataType>, thisArg: any): KoconutCollection<DataType, WrapperType>

    filterTo

    • filterTo(destination: DataType[] | Set<DataType>, predicate: Predicator<DataType>, thisArg: any): KoconutCollection<DataType, WrapperType>

    flatMapIndexedTo

    • flatMapIndexedTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, Iterable<ResultDataType>>, thisArg: any): KoconutCollection<DataType, WrapperType>

    flatMapTo

    • flatMapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, Iterable<ResultDataType>>, thisArg: any): KoconutCollection<DataType, WrapperType>

    groupByTo

    • groupByTo<KeyType, ValueType>(destination: Map<KeyType, ValueType[]>, keySelector: Selector<DataType, KeyType>, valueTransform: null | Transformer<DataType, ValueType>, keySelectorThisArg: any, valueTransformThisArg: any): KoconutCollection<DataType, WrapperType>

    indices

    intersect

    • intersect(other: Iterable<DataType>): KoconutSet<DataType>

    join

    • join(separator?: string, prefix?: string, postfix?: string, limit?: number, truncated?: string, transform?: null | Transformer<DataType, any>, thisArg?: any): KoconutPrimitive<string>

    last

    lastIndexOf

    lastOrNull

    mapIndexedNotNullTo

    • mapIndexedNotNullTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, undefined | null | void | ResultDataType>, thisArg: any): KoconutCollection<DataType, WrapperType>

    mapIndexedTo

    • mapIndexedTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: IndexedTransformer<DataType, ResultDataType>, thisArg: any): KoconutCollection<DataType, WrapperType>

    mapNotNullTo

    • mapNotNullTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, undefined | null | void | ResultDataType>, thisArg: any): KoconutCollection<DataType, WrapperType>

    mapTo

    • mapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<DataType, ResultDataType>, thisArg: any): KoconutCollection<DataType, WrapperType>

    minus

    • minus(elements: DataType | Iterable<DataType>): KoconutCollection<DataType, WrapperType>

    minusElement

    onEach

    onEachIndexed

    partition

    plus

    • plus(elements: DataType | Iterable<DataType>): KoconutCollection<DataType, WrapperType>

    plusElement

    random

    randomOrNull

    reduce

    reduceIndexed

    reduceIndexedOrNull

    reduceOrNull

    retrieve

    reversed

    runningFold

    • runningFold<ResultDataType>(initial: ResultDataType, operation: Operator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    runningFoldIndexed

    • runningFoldIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    runningReduce

    runningReduceIndexed

    scan

    • scan<ResultDataType>(initial: ResultDataType, operation: Operator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    scanIndexed

    • scanIndexed<ResultDataType>(initial: ResultDataType, operation: IndexedOperator<DataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    shuffled

    single

    singleOrNull

    size

    sortedBy

    sortedByDescending

    sortedWith

    subtract

    • subtract(other: Iterable<DataType>): KoconutSet<DataType>

    sumBy

    take

    takeLast

    takeLastWhile

    takeWhile

    union

    • union(other: Iterable<DataType>): KoconutSet<DataType>

    validate

    • validate(data: null | WrapperType): Promise<void>

    windowed

    • windowed<ResultDataType>(size: number, step: number, partialWindows: boolean, transform: null | Transformer<DataType[], ResultDataType>, thisArg: any): KoconutArray<DataType[] | ResultDataType>

    withIndex

    zip

    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: null | Zipper<DataType, OtherDataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType | Pair<DataType, OtherDataType>>
    • zip<OtherDataType>(other: Iterable<OtherDataType>): KoconutArray<Pair<DataType, OtherDataType>>
    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: Zipper<DataType, OtherDataType, ResultDataType>): KoconutArray<ResultDataType>
    • zip<OtherDataType, ResultDataType>(other: Iterable<OtherDataType>, transform: Zipper<DataType, OtherDataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType>

    zipWithNext

    • zipWithNext<ResultDataType>(transform: null | Zipper<DataType, DataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType | Pair<DataType, DataType>>
    • zipWithNext(): KoconutArray<Pair<DataType, DataType>>
    • zipWithNext<ResultDataType>(transform: Zipper<DataType, DataType, ResultDataType>): KoconutArray<ResultDataType>
    • zipWithNext<ResultDataType>(transform: Zipper<DataType, DataType, ResultDataType>, thisArg: any): KoconutArray<ResultDataType>

    Processor Methods

    also

    • also(block: Processor<WrapperType>): Promise<null | WrapperType>
    • 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

      @@ -326,7 +326,7 @@

      Parameters

      • block: Processor<WrapperType>

        A callback function that accepts an argument.

        -

      Returns Promise<null | WrapperType>

    let

    • let<ReturnType>(block: Selector<WrapperType, ReturnType>): Promise<ReturnType>

    Returns Promise<null | WrapperType>

    let

    • let<ReturnType>(block: Selector<WrapperType, 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.

      @@ -335,17 +335,17 @@

      Type parameters

      • ReturnType

      Parameters

      • block: Selector<WrapperType, ReturnType>

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

        -

      Returns Promise<ReturnType>

    process

    • process(): Promise<void>

    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>

    yield

    • yield(): Promise<WrapperType>

    yield

    • yield(): Promise<WrapperType>
    • 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<WrapperType>

    Selector Methods

    elementAt

    Selector Methods

    elementAt

    elementAtOrElse

    Returns KoconutPrimitive<DataType>

    elementAtOrElse

    • Returns an element at the given index or the result of calling the defaultValue function if the index is out of bounds of this collection.

      since

      1.0.10

      @@ -366,14 +366,14 @@

      A callback function that accepts an argument. The method calls the defaultValue function when index is out of bounds.

    • thisArg: any = null

      An object to which the this keyword can refer in the defaultValue. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<DataType>

    elementAtOrNull

    Returns KoconutPrimitive<DataType>

    elementAtOrNull

    • Returns an element at the given index or null if the index is out of bounds of this collection.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const elementAtIndex3OfArray = await koconutArray
      .elementAtOrNull(3)
      .yield()
      console.log(elementAtIndex3OfArray)
      // ↑ 4

      const elementAtIndex10OfArray = await koconutArray
      .elementAtOrNull(10)
      .yield()
      console.log(elementAtIndex10OfArray)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const elementAtIndex2OfSet = await koconutSet
      .elementAtOrNull(2)
      .yield()
      console.log(elementAtIndex2OfSet)
      // ↑ 3

      const elementAtIndexNegative2OfSet = await koconutSet
      .elementAtOrNull(-2)
      .yield()
      console.log(elementAtIndexNegative2OfSet)
      // ↑ null

      Parameters

      • index: number

        The index of element to search for.

        -

      Returns KoconutPrimitive<null | DataType>

    find

    Returns KoconutPrimitive<null | DataType>

    find

    • Returns the first element matching the given predicate, or null if no such element was found.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const foundEventNumberOfArray = await koconutArray
      .find(eachNumber => eachNumber % 2 == 0)
      .yield()
      console.log(foundEventNumberOfArray)
      // ↑ 2

      const foundMultiplesOf10Array = await koconutArray
      .find(eachNumber => eachNumber % 10 == 0)
      .yield()
      console.log(foundMultiplesOf10Array)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const foundOddNumberOfSet = await koconutSet
      .find(eachNumber => eachNumber % 2 == 1)
      .yield()
      console.log(foundOddNumberOfSet)
      // ↑ 1

      const foundMultiplesOf10OfSet = await koconutSet
      .find(eachNumber => eachNumber % 10 == 0)
      .yield()
      console.log(foundMultiplesOf10OfSet)
      // ↑ null @@ -382,7 +382,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    findLast

    Returns KoconutPrimitive<null | DataType>

    findLast

    • Returns the last element matching the given predicate, or null if no such element was found.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const lastEventNumberOfArray = await koconutArray
      .findLast(eachNumber => eachNumber % 2 == 0)
      .yield()
      console.log(lastEventNumberOfArray)
      // ↑ 4

      const lastMultiplesOf10Array = await koconutArray
      .findLast(eachNumber => eachNumber % 10 == 0)
      .yield()
      console.log(lastMultiplesOf10Array)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const lastOddNumberOfSet = await koconutSet
      .findLast(eachNumber => eachNumber % 2 == 1)
      .yield()
      console.log(lastOddNumberOfSet)
      // ↑ 5

      const lastMultiplesOf10OfSet = await koconutSet
      .findLast(eachNumber => eachNumber % 10 == 0)
      .yield()
      console.log(lastMultiplesOf10OfSet)
      // ↑ null @@ -391,7 +391,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    first

    Returns KoconutPrimitive<null | DataType>

    first

    • Returns the first element matching the given predicate. Or, if predicate is omitted method will just return the very first element of this collection. If source data is null or no element matching given predicate is found, it throws KoconutNoSuchElementException.

      @@ -404,7 +404,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<DataType>

    firstOrNull

    Returns KoconutPrimitive<DataType>

    firstOrNull

    • Returns the first element matching the given predicate. Or, if predicate is omitted method will just return the very first element of this collection. If source data is null or no element matching given predicate is found, it returns null.

      @@ -415,14 +415,14 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | DataType>

    indexOf

    Returns KoconutPrimitive<null | DataType>

    indexOf

    • Returns first index of element. or -1 if the collection does not contains element.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const indexOf3 = await koconutArray
      .indexOf(3)
      .yield()
      console.log(indexOf3)
      // ↑ 2

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const indexOf10 = await koconutSet
      .indexOf(10)
      .yield()
      console.log(indexOf10)
      // ↑ -1

      Parameters

      • elementToFind: DataType

        The element to search for.

        -

      Returns KoconutPrimitive<number>

    indexOfFirst

    Returns KoconutPrimitive<number>

    indexOfFirst

    • Returns index of the first element matching the given predicate, or -1 if the collection does not contain such element.

      since

      1.0.10

      @@ -432,7 +432,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<number>

    indexOfLast

    Returns KoconutPrimitive<number>

    indexOfLast

    • Returns index of the last element matching the given predicate, or -1 if the collection does not contain such element.

      since

      1.0.10

      @@ -442,7 +442,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<number>

    Transformer Methods

    associate

    Returns KoconutPrimitive<number>

    Transformer Methods

    associate

    • Returns a KoconutMap containing key-value paired Entry provided by transform function applied to elements of the given collection.

      since

      1.0.10

      @@ -452,7 +452,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    associateBy

    • associateBy<KeyType, ValueType>(keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutMap<KeyType, ValueType>

    Returns KoconutMap<KeyType, ValueType>

    associateBy

    • associateBy<KeyType, ValueType>(keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutMap<KeyType, ValueType>
    • Returns a KoconutMap containing the elements from the given collection indexed by the key returned from keySelector function applied to each element. valueTransform callback function is optional. If it's not omitted the method returns @@ -469,7 +469,7 @@

      An object to which the this keyword can refer in the keySelector. If keySelectorThisArg is omitted, null is used as the this value.

    • valueTransformThisArg: any = null

      An object to which the this keyword can refer in the valueTransform. If valueTransformThisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType>

    associateWith

    • associateWith<ValueType>(valueSelector: Selector<DataType, ValueType>, thisArg?: any): KoconutMap<DataType, ValueType>

    Returns KoconutMap<KeyType, ValueType>

    associateWith

    • associateWith<ValueType>(valueSelector: Selector<DataType, ValueType>, thisArg?: any): KoconutMap<DataType, ValueType>
    • Returns a KoconutMap where keys are original elements of the current object and values are produced by the valueSelector function applied to each element.

      since

      1.0.10

      @@ -479,7 +479,7 @@

      A callback function that accepts an argument. The method calls the valueSelector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the valueSelector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<DataType, ValueType>

    chunked

    • chunked<ResultDataType>(size: number, transform: null | Transformer<DataType[], ResultDataType>, thisArg: any): KoconutArray<ResultDataType | DataType[]>

    Returns KoconutMap<DataType, ValueType>

    chunked

    • chunked<ResultDataType>(size: number, transform: null | Transformer<DataType[], ResultDataType>, thisArg: any): KoconutArray<ResultDataType | DataType[]>

    Returns KoconutArray<ResultDataType | DataType[]>

    flatMap

    • flatMap<ResultDataType>(transform: Transformer<DataType, Iterable<ResultDataType>>, thisArg?: any): KoconutArray<ResultDataType>

    Returns KoconutArray<ResultDataType | DataType[]>

    flatMap

    • flatMap<ResultDataType>(transform: Transformer<DataType, Iterable<ResultDataType>>, thisArg?: any): KoconutArray<ResultDataType>
    • Returns a single list of all elements yielded from results of transform function being invoked on each element of original collection.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of("123", "45")

      const allNumberInArray = await koconutArray
      .flatMap(eachString => eachString)
      // ↑ The string itself can be used as Iterable<string>.
      // If you want to make it clear, also possible to type
      // as eachString => eachString.split('')
      .map(parseInt)
      .yield()
      console.log(allNumberInArray)
      // ↑ [ 1, 2, 3, 4, 5 ]

      // Case 2 - KoconutSet
      const koconutSet = KoconutSet.of("abc", "de")

      const allCharactersInSet = await koconutSet
      .flatMap(eachString => eachString)
      .yield()
      console.log(allCharactersInSet)
      // ↑ [ 'a', 'b', 'c', 'd', 'e' ]

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associateWith(eachNumber => eachNumber * 2)

      const allKeysAndValuesInMap = await koconutMap
      .flatMap(eachEntry => [eachEntry.key, eachEntry.value])
      .yield()
      console.log(allKeysAndValuesInMap)
      // ↑ [1, 2, 2, 4, 3, 6, 4, 8, 5, 10]


      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(123, 987)

      const allDigitsInArray = await koconutArray2
      .flatMap(async eachNumber => {
      const digits = new Array<number>()
      while(eachNumber != 0) {
      digits.unshift(eachNumber % 10)
      eachNumber = Math.floor(eachNumber / 10)
      }
      return digits
      })
      .yield()
      console.log(allDigitsInArray)
      // ↑ [ 1, 2, 3, 9, 8, 7 ]

      const allNumberCharactersInArray = await koconutArray2
      .flatMap(eachNumber => new Promise<string>(resolve => {
      resolve(eachNumber.toString())
      }))
      .yield()
      console.log(allNumberCharactersInArray)
      // ↑ [ '1', '2', '3', '9', '8', '7' ] @@ -502,7 +502,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    flatMapIndexed

    Returns KoconutArray<ResultDataType>

    flatMapIndexed

    • Returns a KoconutArray of all elements yielded from results of transform function being invoked on each element of original collection.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(100, 101, 102)

      const allNumbersAndIndexOfArray = await koconutArray
      .flatMapIndexed((eachIndex, eachNumber) =>
      [eachIndex, eachNumber]
      )
      .yield()
      console.log(allNumbersAndIndexOfArray)
      // ↑ [ 0, 100, 1, 101, 2, 102 ]

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(100, 101, 102)

      const allNumbersAndIndexOfSet = await koconutSet
      .flatMapIndexed((eachIndex, eachNumber) =>
      [eachIndex, eachNumber]
      )
      .yield()
      console.log(allNumbersAndIndexOfSet)
      // ↑ [ 0, 100, 1, 101, 2, 102 ]

      // Case 3 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(123, 987)

      const allDigitsAndIndexInArray = await koconutArray2
      .flatMapIndexed(async (eachIndex, eachNumber) => {
      const digits = new Array<number>()
      while(eachNumber != 0) {
      digits.unshift(eachNumber % 10)
      eachNumber = Math.floor(eachNumber / 10)
      }
      return [eachIndex, ...digits]
      })
      .yield()
      console.log(allDigitsAndIndexInArray)
      // ↑ [
      // 0, 1, 2, 3,
      // 1, 9, 8, 7
      // ]

      const allNumberAndIndexCharactersInArray = await koconutArray2
      .flatMapIndexed((eachInex, eachNumber) => new Promise<string>(resolve => {
      resolve(`${eachInex}${eachNumber}`)
      }))
      .yield()
      console.log(allNumberAndIndexCharactersInArray)
      // ↑ [
      // '0', '1', '2',
      // '3', '1', '9',
      // '8', '7'
      // ] @@ -511,7 +511,7 @@

      A callback function that accepts two arguments. The method calls the transform one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    groupBy

    • groupBy<KeyType, ValueType>(keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutMap<KeyType, ValueType[]>

    Returns KoconutArray<ResultDataType>

    groupBy

    • groupBy<KeyType, ValueType>(keySelector: Selector<DataType, KeyType>, valueTransform?: null | Transformer<DataType, ValueType>, keySelectorThisArg?: any, valueTransformThisArg?: any): KoconutMap<KeyType, ValueType[]>
    • Groups values returned by the valueTransform function applied to each element of the original collection by the key returned by the given keySelector function applied to the element and returns a map where each group key is associated with a list of corresponding values. If valueTransform is omitted, the value of @@ -527,7 +527,7 @@

      An object to which the this keyword can refer in the keySelector. If keySelectorThisArg is omitted, null is used as the this value.

    • valueTransformThisArg: any = null

      An object to which the this keyword can refer in the valueTransform. If valueTransformThisArg is omitted, null is used as the this value.

      -

    Returns KoconutMap<KeyType, ValueType[]>

    map

    Returns KoconutMap<KeyType, ValueType[]>

    map

    • Returns a list containing the results of applying the given transform function to each element in the original collection.

      since

      1.0.10

      @@ -537,7 +537,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    mapIndexed

    Returns KoconutArray<ResultDataType>

    mapIndexed

    • Returns a list of all elements yielded from results of transform function being invoked on each element and its index in the original collection.

      since

      1.0.10

      @@ -547,7 +547,7 @@

      A callback function that accepts two arguments. The method calls the transform one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    mapIndexedNotNull

    • mapIndexedNotNull<ResultDataType>(transform: IndexedTransformer<DataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    Returns KoconutArray<ResultDataType>

    mapIndexedNotNull

    • mapIndexedNotNull<ResultDataType>(transform: IndexedTransformer<DataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>
    • Returns a KoconutArray containing only the results that are not null nor undefined of applying the given transform function to each element and its index in the original collection.

      since

      1.0.10

      @@ -557,7 +557,7 @@

      A callback function that accepts two arguments. The method calls the transform one time for each index and element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    mapNotNull

    • mapNotNull<ResultDataType>(transform: Transformer<DataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    Returns KoconutArray<ResultDataType>

    mapNotNull

    • mapNotNull<ResultDataType>(transform: Transformer<DataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    maxBy

    Returns KoconutPrimitive<number>

    maxBy

    Returns KoconutPrimitive<CombinedDataType>

    maxByOrNull

    Returns KoconutPrimitive<CombinedDataType>

    maxByOrNull

    • Returns the first element yielding the largest value of the given function or null if there are no elements.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const largestNumberOfArray = await koconutArray
      .maxByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(largestNumberOfArray)
      // ↑ 5


      const largestNumberOfEmptyArray = await koconutArray
      .filter(eachNumber => eachNumber > 10)
      .maxByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(largestNumberOfEmptyArray)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of("a", "ab", "abc")

      const longestStringOfSet = await koconutSet
      .maxByOrNull(eachString => eachString.length)
      .yield()
      console.log(longestStringOfSet)
      // ↑ abc

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1, 12, 123)
      .associateWith(eachNumber => eachNumber.toString())

      const longestDigitsEntryOfMap = await koconutMap
      .maxByOrNull(eachEntry => eachEntry.value.length)
      .yield()
      console.log(longestDigitsEntryOfMap)
      // ↑ Entry { keyElement: 123, valueElement: '123' }

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(19,27,32)

      const largestNumberOfArray2 = await koconutArray2
      .maxByOrNull(async eachNumber => eachNumber)
      .yield()
      console.log(largestNumberOfArray2)
      // ↑ 32

      const largest1sDigitNumberOfArray2 = await koconutArray2
      .maxByOrNull(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 10)
      }))
      .yield()
      console.log(largest1sDigitNumberOfArray2)
      // ↑ 19 @@ -28,7 +28,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | CombinedDataType>

    maxOf

    • maxOf<ComparableType>(selector: Selector<CombinedDataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutPrimitive<null | CombinedDataType>

    maxOf

    • maxOf<ComparableType>(selector: Selector<CombinedDataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>
    • Returns the largest value among all values produced by selector function applied to each element in the collection or throws KoconutNoSuchElementException if there are no elements.

      throws

      KoconutNoSuchElementException

      @@ -39,7 +39,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<string | number | ComparableType>

    maxOfOrNull

    • maxOfOrNull<ComparableType>(selector: Selector<CombinedDataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    maxOfOrNull

    • maxOfOrNull<ComparableType>(selector: Selector<CombinedDataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>
    • Returns the largest value among all values produced by selector function applied to each element in the collection or null if there are no elements.

      since

      1.0.10

      @@ -49,7 +49,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | string | number | ComparableType>

    maxOfWith

    • maxOfWith<ResultDataType>(selector: Selector<CombinedDataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>

    Returns KoconutPrimitive<null | string | number | ComparableType>

    maxOfWith

    • maxOfWith<ResultDataType>(selector: Selector<CombinedDataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>
    • Returns the largest value according to the provided comparator among all values produced by selector function applied to each element in the collection all throws KoconutNoSuchElementException if elements are empty.

      @@ -66,7 +66,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<ResultDataType>

    maxOfWithOrNull

    • maxOfWithOrNull<ResultDataType>(selector: Selector<CombinedDataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>

    Returns KoconutPrimitive<ResultDataType>

    maxOfWithOrNull

    • maxOfWithOrNull<ResultDataType>(selector: Selector<CombinedDataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>
    • Returns the largest value according to the provided comparator among all values produced by selector function applied to each element in the collection or null if elements are empty.

      @@ -82,7 +82,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | ResultDataType>

    maxWith

    Returns KoconutPrimitive<null | ResultDataType>

    maxWith

    Returns KoconutPrimitive<CombinedDataType>

    maxWithOrNull

    Returns KoconutPrimitive<CombinedDataType>

    maxWithOrNull

    • Returns the first element having the largest value according to the provided comparator or null if elements are empty.

      since

      1.0.10

      @@ -105,7 +105,7 @@ In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.

    • thisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | CombinedDataType>

    minBy

    Returns KoconutPrimitive<null | CombinedDataType>

    minBy

    Returns KoconutPrimitive<CombinedDataType>

    minByOrNull

    Returns KoconutPrimitive<CombinedDataType>

    minByOrNull

    • Returns the first element yielding the smallest value of the given function or null if there are no elements.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const smallestNumberOfArray = await koconutArray
      .minByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(smallestNumberOfArray)
      // ↑ 1

      const smallestNumberOfEmptyArray = await koconutArray
      .filter(eachNumber => eachNumber > 10)
      .minByOrNull(eachNumber => eachNumber)
      .yield()
      console.log(smallestNumberOfEmptyArray)
      // ↑ null

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of("a", "ab", "abc")

      const shortestStringOfSet = await koconutSet
      .minByOrNull(eachString => eachString.length)
      .yield()
      console.log(shortestStringOfSet)
      // ↑ a

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1, 12, 123)
      .associateWith(eachNumber => eachNumber.toString())

      const shortestDigitsEntryOfMap = await koconutMap
      .minByOrNull(eachEntry => eachEntry.value.length)
      .yield()
      console.log(shortestDigitsEntryOfMap)
      // ↑ Entry { keyElement: 1, valueElement: '1' }

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(19,27,32)

      const smallestNumberOfArray2 = await koconutArray2
      .minByOrNull(async eachNumber => eachNumber)
      .yield()
      console.log(smallestNumberOfArray2)
      // ↑ 19

      const smallest1sDigitNumberOfArray2 = await koconutArray2
      .minByOrNull(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 10)
      }))
      .yield()
      console.log(smallest1sDigitNumberOfArray2)
      // ↑ 32 @@ -126,7 +126,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | CombinedDataType>

    minOf

    • minOf<ComparableType>(selector: Selector<CombinedDataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>

    Returns KoconutPrimitive<null | CombinedDataType>

    minOf

    • minOf<ComparableType>(selector: Selector<CombinedDataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<string | number | ComparableType>
    • Returns the smallest value among all values produced by selector function applied to each element in the collection or throws KoconutNoSuchElementException if there are no elements.

      throws

      KoconutNoSuchElementException

      @@ -137,7 +137,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<string | number | ComparableType>

    minOfOrNull

    • minOfOrNull<ComparableType>(selector: Selector<CombinedDataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>

    Returns KoconutPrimitive<string | number | ComparableType>

    minOfOrNull

    • minOfOrNull<ComparableType>(selector: Selector<CombinedDataType, string | number | ComparableType>, thisArg: any): KoconutPrimitive<null | string | number | ComparableType>
    • Returns the smallest value among all values produced by selector function applied to each element in the collection or null if there are no elements.

      since

      1.0.10

      @@ -147,7 +147,7 @@

      A callback function that accepts an argument. The method calls the selector one time for each element in object.

    • thisArg: any

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | string | number | ComparableType>

    minOfWith

    • minOfWith<ResultDataType>(selector: Selector<CombinedDataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>

    Returns KoconutPrimitive<null | string | number | ComparableType>

    minOfWith

    • minOfWith<ResultDataType>(selector: Selector<CombinedDataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<ResultDataType>
    • Returns the smallest value according to the provided comparator among all values produced by selector function applied to each element in the collection all throws KoconutNoSuchElementException if elements are empty.

      @@ -164,7 +164,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<ResultDataType>

    minOfWithOrNull

    • minOfWithOrNull<ResultDataType>(selector: Selector<CombinedDataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>

    Returns KoconutPrimitive<ResultDataType>

    minOfWithOrNull

    • minOfWithOrNull<ResultDataType>(selector: Selector<CombinedDataType, ResultDataType>, comparator: Comparator<ResultDataType>, selectorThisArg?: any, comparatorThisArg?: any): KoconutPrimitive<null | ResultDataType>
    • Returns the smallest value according to the provided comparator among all values produced by selector function applied to each element in the collection all null if elements are empty.

      @@ -181,7 +181,7 @@

      An object to which the this keyword can refer in the selector. If thisArg is omitted, null is used as the this value.

    • comparatorThisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | ResultDataType>

    minWith

    Returns KoconutPrimitive<null | ResultDataType>

    minWith

    • Returns the first element having the smallest value according to the provided comparator or throws KoconutNoSuchElementException if elements are empty.

      throws

      KoconutNoSuchElementException

      @@ -193,7 +193,7 @@ In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.

    • thisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<CombinedDataType>

    minWithOrNull

    Returns KoconutPrimitive<CombinedDataType>

    minWithOrNull

    • Returns the first element having the smallest value according to the provided comparator or null if elements are empty.

      since

      1.0.10

      @@ -204,17 +204,17 @@ In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.

    • thisArg: any = null

      An object to which the this keyword can refer in the comparator. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<null | CombinedDataType>

    Caster Methods

    asArray

    Returns KoconutPrimitive<null | CombinedDataType>

    Caster Methods

    asArray

    • Creates an KoconutArray instance that wraps original data.

      since

      1.0.13

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const arrToArr = await koconutArray
      .asArray()
      .yield()
      console.log(arrToArr)
      // ↑ [ 1, 2, 3, 4, 5 ]

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,1,2,2,3,3,4,4,5,5)

      const setToArr = await koconutSet
      .asArray()
      .yield()
      console.log(setToArr)
      // ↑ [ 1, 2, 3, 4, 5 ]

      // Case 3 -- KoconutFlow
      const koconutFlow = KoconutFlow.ofSimple(1,2,3,4,5)

      const flowToArr = await koconutFlow
      .asArray()
      .yield()
      console.log(flowToArr)
      // ↑
      // [
      // Entry { keyElement: 0, valueElement: 1 },
      // Entry { keyElement: 1, valueElement: 2 },
      // Entry { keyElement: 2, valueElement: 3 },
      // Entry { keyElement: 3, valueElement: 4 },
      // Entry { keyElement: 4, valueElement: 5 }
      // ]

      // Case 4 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber])

      const mapToArr = await koconutMap
      .asArray()
      .yield()
      console.log(mapToArr)
      // ↑
      // [
      // Entry { keyElement: 1, valueElement: 1 },
      // Entry { keyElement: 2, valueElement: 2 },
      // Entry { keyElement: 3, valueElement: 3 },
      // Entry { keyElement: 4, valueElement: 4 },
      // Entry { keyElement: 5, valueElement: 5 }
      // ]
      -

      Returns KoconutArray<CombinedDataType>

    asSet

    asSet

    • Creates an KoconutSet instance that wraps original data.

      since

      1.0.13

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const arrToSet = await koconutArray
      .asSet()
      .yield()
      console.log(arrToSet)
      // ↑ Set { 1, 2, 3, 4, 5 }

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,1,2,2,3,3,4,4,5,5)

      const setToSet = await koconutSet
      .asSet()
      .yield()
      console.log(setToSet)
      // ↑ Set { 1, 2, 3, 4, 5 }

      // Case 3 -- KoconutFlow
      const koconutFlow = KoconutFlow.ofSimple(1,2,3,4,5)

      const flowToSet = await koconutFlow
      .asSet()
      .yield()
      console.log(flowToSet)
      // ↑
      // Set {
      // Entry { keyElement: 0, valueElement: 1 },
      // Entry { keyElement: 1, valueElement: 2 },
      // Entry { keyElement: 2, valueElement: 3 },
      // Entry { keyElement: 3, valueElement: 4 },
      // Entry { keyElement: 4, valueElement: 5 }
      // }

      // Case 4 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associate(eachNumber => [eachNumber, eachNumber])

      const mapToSet = await koconutMap
      .asSet()
      .yield()
      console.log(mapToSet)
      // ↑
      // Set {
      // Entry { keyElement: 1, valueElement: 1 },
      // Entry { keyElement: 2, valueElement: 2 },
      // Entry { keyElement: 3, valueElement: 3 },
      // Entry { keyElement: 4, valueElement: 4 },
      // Entry { keyElement: 5, valueElement: 5 }
      // }
      -

      Returns KoconutSet<CombinedDataType>

    Inspector Methods

    all

    Inspector Methods

    all

    • Return true if all elements match te given predicate.

      since

      1.0.10

      example
        // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const areAllArrayElementsGreaterThan0 = await koconutArray
      .all(eachNumber => eachNumber > 0)
      .yield()
      console.log(areAllArrayElementsGreaterThan0)
      // ↑ true

      const areAllArrayElementsEven = await koconutArray
      .all(eachNumber => eachNumber % 2 == 0)
      .yield()
      console.log(areAllArrayElementsEven)
      // ↑ false -- i.e. '1' is not an even number.


      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const areAllSetElementsGreaterThan0 = await koconutSet
      .all(eachNumber => eachNumber > 0)
      .yield()
      console.log(areAllSetElementsGreaterThan0)
      // ↑ true

      const areAllSetElementsOdd = await koconutSet
      .all(eachNumber => eachNumber % 2 == 1)
      .yield()
      console.log(areAllSetElementsOdd)
      // ↑ false -- i.e. '2' is not an odd number.


      // Case 3 -- KoconutMap
      const koconutMap = KoconutMap.of(
      [0, 0],
      [1, 1],
      [2, 2]
      )

      const areAllMapEntriesKeyEqualsToValue = await koconutMap
      .all(eachEntry => eachEntry.key == eachEntry.value)
      .yield()
      console.log(areAllMapEntriesKeyEqualsToValue)
      // ↑ true

      const areAllMapEntriesSumGreaterThan3 = await koconutMap
      .all(eachEntry => eachEntry.key + eachEntry.value > 3)
      .yield()
      console.log(areAllMapEntriesSumGreaterThan3)
      // ↑ false -- i.e. Sum of key and value of first Entry { 0, 0 } is 0.
      // It's definetly less than 3

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(1,2,3,4,5)

      const areAllArrayElementsLessThan10 = await koconutArray2
      .all(async eachNumber => eachNumber < 10)
      .yield()
      console.log(areAllArrayElementsLessThan10)
      // ↑ true

      const areAllArrayElementsOdd = await koconutArray2
      .all(eachNumber => new Promise(resolve => {
      resolve(eachNumber % 2 == 1)
      }))
      .yield()
      console.log(areAllArrayElementsOdd)
      // ↑ false -- i.e. '2' is not an odd number. @@ -223,7 +223,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutBoolean

    any

    Returns KoconutBoolean

    any

    • Returns true if the collection has at least one element matches the given predicate.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isAnyArrayElementGreaterThan4 = await koconutArray
      .any(eachNumber => eachNumber > 4)
      .yield()
      console.log(isAnyArrayElementGreaterThan4)
      // ↑ true -- i.e. '5' is greater than 4.

      const isAnyArrayElementMultipleOf6 = await koconutArray
      .any(eachNumber => eachNumber % 6 == 0)
      .yield()
      console.log(isAnyArrayElementMultipleOf6)
      // ↑ false

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isAnySetElementGreaterThan3 = await koconutSet
      .any(eachNumber => eachNumber > 3)
      .yield()
      console.log(isAnySetElementGreaterThan3)
      // ↑ true -- i.e. '4' is greater than 3.

      const isAnySetElementLessThan0 = await koconutSet
      .any(eachNumber => eachNumber < 0)
      .yield()
      console.log(isAnySetElementLessThan0)
      // ↑ false

      // Case 3 -- KoconutMap
      const koconutMap = KoconutMap.of(
      [0, 0],
      [1, 1],
      [2, 2]
      )

      const isAnyMapEntrySumGreaterThan3 = await koconutMap
      .any(eachEntry => eachEntry.key + eachEntry.value > 3)
      .yield()
      console.log(isAnyMapEntrySumGreaterThan3)
      // ↑ true -- i.e. Sum of key and value of third Entry { 2, 2 } is 4.
      // It's grater than 4.

      const isAnyMapEntryKeyMultipleOf4 = await koconutMap
      .any(eachEntry => eachEntry.key > 0 && eachEntry.key % 4 == 0)
      .yield()
      console.log(isAnyMapEntryKeyMultipleOf4)
      // ↑ false

      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(1,2,3,4,5)

      const isAnyArrayElementLessThan2 = await koconutArray2
      .any(async eachNumber => eachNumber < 2)
      .yield()
      console.log(isAnyArrayElementLessThan2)
      // ↑ true -- i.e. '1' is less than 2.

      const isAnyArrayElementGreaterThan7 = await koconutArray2
      .any(eachNumber => new Promise(resolve => {
      resolve(eachNumber > 7)
      }))
      .yield()
      console.log(isAnyArrayElementGreaterThan7)
      // ↑ false @@ -232,24 +232,24 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutBoolean

    isEmpty

    Returns KoconutBoolean

    isEmpty

    • Returns true if the collection is empty (contains no elements), false otherwise.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isNumberArrayEmpty = await koconutArray
      .isEmpty()
      .yield()
      console.log(isNumberArrayEmpty)
      // ↑ false

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isFilteredNumberSetEmpty = await koconutSet
      .filter(eachNumber => eachNumber > 10)
      .isEmpty()
      .yield()
      console.log(isFilteredNumberSetEmpty)
      // ↑ true

      // Case 3 -- KoconutMap
      const koconutMap = new KoconutMap<number, number>()

      const isNumberPairedMapEmpty = await koconutMap
      .isEmpty()
      .yield()
      console.log(isNumberPairedMapEmpty)
      // ↑ true
      -

      Returns KoconutBoolean

    isNotEmpty

    isNotEmpty

    • Returns true if the collection is not empty.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isNumberArrayEmpty = await koconutArray
      .isNotEmpty()
      .yield()
      console.log(isNumberArrayEmpty)
      // ↑ true

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isFilteredNumberSetEmpty = await koconutSet
      .filter(eachNumber => eachNumber > 10)
      .isNotEmpty()
      .yield()
      console.log(isFilteredNumberSetEmpty)
      // ↑ false

      // Case 3 -- KoconutMap
      const koconutMap = new KoconutMap<number, number>()

      const isNumberPairedMapEmpty = await koconutMap
      .isNotEmpty()
      .yield()
      console.log(isNumberPairedMapEmpty)
      // ↑ false
      -

      Returns KoconutBoolean

    isNullOrEmpty

    isNullOrEmpty

    • Returns true if this nullable collection is either null or empty.

      since

      1.0.10

      deprecated

      Use isEmpty instead.

      until

      1.3.0

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of(1,2,3,4,5)

      const isNumberArrayEmpty = await koconutArray
      .isNullOrEmpty()
      .yield()
      console.log(isNumberArrayEmpty)
      // ↑ false

      // Case 2 -- KoconutSet
      const koconutSet = KoconutSet.of(1,2,3,4,5)

      const isFilteredNumberSetEmpty = await koconutSet
      .filter(eachNumber => eachNumber > 10)
      .isNullOrEmpty()
      .yield()
      console.log(isFilteredNumberSetEmpty)
      // ↑ true

      // Case 3 -- KoconutMap
      const koconutMap = new KoconutMap<number, number>()

      const isNumberPairedMapEmpty = await koconutMap
      .isNullOrEmpty()
      .yield()
      console.log(isNumberPairedMapEmpty)
      // ↑ true
      -

      Returns KoconutBoolean

    none

    none

    • predicate callback function is optional. If it's omitted the method returns true if the collection has no elements. Otherwise, returns true if no elements match the given predicate.

      since

      1.0.10

      @@ -259,7 +259,7 @@

      A callback function that accepts an argument. The method calls the predicate one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the predicate. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutBoolean

    Iterator Methods

    forEach

    Returns KoconutBoolean

    Iterator Methods

    forEach

    • Performs the given action on each element. When you want to stop iteration in the meantime return false or KoconutLoopSignal.BREAK.

      since

      1.0.10

      @@ -269,7 +269,7 @@

      A callback function that accepts an argument. The method calls the action one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the action. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutPrimitive<void>

    Other Methods

    filter

    • filter(predicate: Predicator<CombinedDataType>, thisArg: any): KoconutIterable<DataType, CombinedDataType, WrapperType, CombinedWrapperType>

    filterNot

    • filterNot(predicate: Predicator<CombinedDataType>, thisArg: any): KoconutIterable<DataType, CombinedDataType, WrapperType, CombinedWrapperType>

    flatMapTo

    • flatMapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<CombinedDataType, Iterable<ResultDataType>>, thisArg: any): KoconutIterable<DataType, CombinedDataType, WrapperType, CombinedWrapperType>

    mapNotNullTo

    • mapNotNullTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<CombinedDataType, undefined | null | void | ResultDataType>, thisArg: any): KoconutIterable<DataType, CombinedDataType, WrapperType, CombinedWrapperType>

    mapTo

    • mapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<CombinedDataType, ResultDataType>, thisArg: any): KoconutIterable<DataType, CombinedDataType, WrapperType, CombinedWrapperType>

    onEach

    • onEach(action: Action<CombinedDataType>, thisArg: any): KoconutIterable<DataType, CombinedDataType, WrapperType, CombinedWrapperType>

    retrieve

    Processor Methods

    also

    • also(block: Processor<WrapperType>): Promise<null | WrapperType>

    Returns KoconutPrimitive<void>

    Other Methods

    filter

    • filter(predicate: Predicator<CombinedDataType>, thisArg: any): KoconutIterable<DataType, CombinedDataType, WrapperType, CombinedWrapperType>

    filterNot

    • filterNot(predicate: Predicator<CombinedDataType>, thisArg: any): KoconutIterable<DataType, CombinedDataType, WrapperType, CombinedWrapperType>

    flatMapTo

    • flatMapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<CombinedDataType, Iterable<ResultDataType>>, thisArg: any): KoconutIterable<DataType, CombinedDataType, WrapperType, CombinedWrapperType>

    mapNotNullTo

    • mapNotNullTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<CombinedDataType, undefined | null | void | ResultDataType>, thisArg: any): KoconutIterable<DataType, CombinedDataType, WrapperType, CombinedWrapperType>

    mapTo

    • mapTo<ResultDataType>(destination: ResultDataType[] | Set<ResultDataType>, transform: Transformer<CombinedDataType, ResultDataType>, thisArg: any): KoconutIterable<DataType, CombinedDataType, WrapperType, CombinedWrapperType>

    onEach

    • onEach(action: Action<CombinedDataType>, thisArg: any): KoconutIterable<DataType, CombinedDataType, WrapperType, CombinedWrapperType>

    retrieve

    Processor Methods

    also

    • also(block: Processor<WrapperType>): Promise<null | WrapperType>
    • 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

      @@ -277,7 +277,7 @@

      Parameters

      • block: Processor<WrapperType>

        A callback function that accepts an argument.

        -

      Returns Promise<null | WrapperType>

    let

    • let<ReturnType>(block: Selector<WrapperType, ReturnType>): Promise<ReturnType>

    Returns Promise<null | WrapperType>

    let

    • let<ReturnType>(block: Selector<WrapperType, 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.

      @@ -286,17 +286,17 @@

      Type parameters

      • ReturnType

      Parameters

      • block: Selector<WrapperType, ReturnType>

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

        -

      Returns Promise<ReturnType>

    process

    • process(): Promise<void>

    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>

    yield

    • yield(): Promise<WrapperType>

    yield

    • yield(): Promise<WrapperType>
    • 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<WrapperType>

    Transformer Methods

    flatMap

    • flatMap<ResultDataType>(transform: Transformer<CombinedDataType, Iterable<ResultDataType>>, thisArg?: any): KoconutArray<ResultDataType>

    Transformer Methods

    flatMap

    • flatMap<ResultDataType>(transform: Transformer<CombinedDataType, Iterable<ResultDataType>>, thisArg?: any): KoconutArray<ResultDataType>
    • Returns a single list of all elements yielded from results of transform function being invoked on each element of original collection.

      since

      1.0.10

      example
      // Case 1 -- KoconutArray
      const koconutArray = KoconutArray.of("123", "45")

      const allNumberInArray = await koconutArray
      .flatMap(eachString => eachString)
      // ↑ The string itself can be used as Iterable<string>.
      // If you want to make it clear, also possible to type
      // as eachString => eachString.split('')
      .map(parseInt)
      .yield()
      console.log(allNumberInArray)
      // ↑ [ 1, 2, 3, 4, 5 ]

      // Case 2 - KoconutSet
      const koconutSet = KoconutSet.of("abc", "de")

      const allCharactersInSet = await koconutSet
      .flatMap(eachString => eachString)
      .yield()
      console.log(allCharactersInSet)
      // ↑ [ 'a', 'b', 'c', 'd', 'e' ]

      // Case 3 -- KoconutMap
      const koconutMap = KoconutArray.of(1,2,3,4,5)
      .associateWith(eachNumber => eachNumber * 2)

      const allKeysAndValuesInMap = await koconutMap
      .flatMap(eachEntry => [eachEntry.key, eachEntry.value])
      .yield()
      console.log(allKeysAndValuesInMap)
      // ↑ [1, 2, 2, 4, 3, 6, 4, 8, 5, 10]


      // Case 4 -- You can also do it asynchronously
      const koconutArray2 = KoconutArray.of(123, 987)

      const allDigitsInArray = await koconutArray2
      .flatMap(async eachNumber => {
      const digits = new Array<number>()
      while(eachNumber != 0) {
      digits.unshift(eachNumber % 10)
      eachNumber = Math.floor(eachNumber / 10)
      }
      return digits
      })
      .yield()
      console.log(allDigitsInArray)
      // ↑ [ 1, 2, 3, 9, 8, 7 ]

      const allNumberCharactersInArray = await koconutArray2
      .flatMap(eachNumber => new Promise<string>(resolve => {
      resolve(eachNumber.toString())
      }))
      .yield()
      console.log(allNumberCharactersInArray)
      // ↑ [ '1', '2', '3', '9', '8', '7' ] @@ -305,7 +305,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    map

    • map<ResultDataType>(transform: Transformer<CombinedDataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    Returns KoconutArray<ResultDataType>

    map

    • map<ResultDataType>(transform: Transformer<CombinedDataType, ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>
    • Returns a list containing the results of applying the given transform function to each element in the original collection.

      since

      1.0.10

      @@ -315,7 +315,7 @@

      A callback function that accepts an argument. The method calls the transform one time for each element in object.

    • thisArg: any = null

      An object to which the this keyword can refer in the transform. If thisArg is omitted, null is used as the this value.

      -

    Returns KoconutArray<ResultDataType>

    mapNotNull

    • mapNotNull<ResultDataType>(transform: Transformer<CombinedDataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    Returns KoconutArray<ResultDataType>

    mapNotNull

    • mapNotNull<ResultDataType>(transform: Transformer<CombinedDataType, undefined | null | void | ResultDataType>, thisArg?: any): KoconutArray<ResultDataType>

    process

    • process(): Promise<void>

    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>

    yield

    • yield(): Promise<DataType>

    yield

    • yield(): Promise<DataType>