From e9b1bfc65909b94fd45cdbc4a5f528c669247dba Mon Sep 17 00:00:00 2001 From: ApexCaptain Date: Mon, 13 Dec 2021 11:53:55 +0900 Subject: [PATCH] New version released : 1.0.163 --- .ToDo | 30 +- .babelrc | 28 +- .editorconfig | 10 + .github/workflows/manual-ci.yml | 2 +- .github/workflows/pipeline.yml | 16 +- .gitignore | 8 +- .prettierrc | 2 +- CHANGELOG.md | 435 +++--- LICENSE | 402 ++--- README.md | 1356 ++++++++--------- bower.json | 1 + desktop.ini | 12 +- .../container/base/KoconutBoolean.d.ts | 20 +- .../{tool => protocol}/KoconutYieldable.d.ts | 0 .../{tool => protocol}/KoconutYieldable.js | 0 dist/index.js | 2 + dist/module.d.ts | 2 +- dist/module.js | 27 +- 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 +- docs/enums/KoconutLocale.html | 2 +- docs/enums/KoconutLoopSignal.html | 2 +- docs/index.html | 85 +- 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 | 4 +- tsconfig.json | 38 +- typedoc.json | 18 +- 48 files changed, 1688 insertions(+), 1606 deletions(-) create mode 100644 .editorconfig rename dist/components/{tool => protocol}/KoconutYieldable.d.ts (100%) rename dist/components/{tool => protocol}/KoconutYieldable.js (100%) diff --git a/.ToDo b/.ToDo index 18d2710..f2d19a5 100644 --- a/.ToDo +++ b/.ToDo @@ -1,23 +1,7 @@ -API 문서화 -- 참조 : https://typedoc.org/guides/doccomments/ - -로고/프로젝트 카드 작성 - -Container 내부에서 Git 커맨드 사용 (SSH 키 써서) - -v 1.0.163 - 변경사항 -메소드 오타 체크 -KoconutMap - mapVaues -> mapValues - -KoconutCollection - substract -> subtract - runningFoldindexed -> runningFoldIndexed - - - -// Currently working on... ---- -iterable -> maxOf // maxOfOrNull 함수에 대해서는 매뉴얼 테스트 진행 해봐야 할 듯... - ---- -iterable -> minWith 부터 작업 재개 \ No newline at end of file +API 문서화 -- 참조 : https://typedoc.org/guides/doccomments/ + +로고/프로젝트 카드 작성 + +Container 내부에서 Git 커맨드 사용 (SSH 키 써서) + +// Currently working on... diff --git a/.babelrc b/.babelrc index bbef07f..30eef9a 100644 --- a/.babelrc +++ b/.babelrc @@ -1,14 +1,14 @@ -{ - "presets": [ - "@babel/preset-env", - ["@babel/preset-typescript", {"allowNamespaces" : true, "modules": false}] - ], - "plugins": [ - "@babel/proposal-class-properties", - "@babel/proposal-object-rest-spread", - "@babel/syntax-dynamic-import", - "@babel/plugin-transform-runtime", - "@babel/transform-async-to-generator" - ], - "comments": false -} \ No newline at end of file +{ + "presets": [ + "@babel/preset-env", + ["@babel/preset-typescript", {"allowNamespaces" : true, "modules": false}] + ], + "plugins": [ + "@babel/proposal-class-properties", + "@babel/proposal-object-rest-spread", + "@babel/syntax-dynamic-import", + "@babel/plugin-transform-runtime", + "@babel/transform-async-to-generator" + ], + "comments": false +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..efd97fb --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[**] +charset = utf-8 +insert_final_newline = true +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = true diff --git a/.github/workflows/manual-ci.yml b/.github/workflows/manual-ci.yml index 841dfc4..a6f6e93 100644 --- a/.github/workflows/manual-ci.yml +++ b/.github/workflows/manual-ci.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: - os: [ubuntu-latest] # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions + os: [ubuntu-latest] node-version: [12.x, 13.x, 14.x, 15.x, 16.x] steps: diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 2c8b0ed..0c5fa19 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -3,7 +3,7 @@ name: Pipeline on: push: tags: - - "*.*.*" + - '*.*.*' jobs: ci: @@ -11,7 +11,17 @@ jobs: strategy: matrix: - os: [ubuntu-latest, windows-latest, windows-2016, macos-latest] # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions + os: [ + # Ubuntu + ubuntu-18.04, + ubuntu-latest, + # Windows + 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] runs-on: ${{matrix.os}} @@ -44,7 +54,7 @@ jobs: - name: Use Node.js v16 uses: actions/setup-node@v2 with: - node-version: "16.x" + node-version: '16.x' registry-url: https://registry.npmjs.org/ - run: npm publish env: diff --git a/.gitignore b/.gitignore index 65dbd65..7aaa0f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -/node_modules -Icon -/log -*.log \ No newline at end of file +/node_modules +Icon +/log +*.log diff --git a/.prettierrc b/.prettierrc index 33ffd8c..f2c389a 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,4 +3,4 @@ "singleQuote": true, "tabWidth": 2, "trailingComma": "all" -} \ No newline at end of file +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f1ecd5..536c51d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,203 +1,232 @@ -# Koconut Release Note - -
- -## Release **v1.0.162** - -
-8 Dec 2021 -
- -### Bug Fixes and Other Changes - -- Fix some methods that did not print out intelliSence description of method example source. - -### Known Caveats - -- Changed the minimum Node.js version from 7 to 12 in order to follow [node.js release and maintenance policy](https://nodejs.org/en/about/releases/). - -### Repository - -- [API Document Page](https://apexcaptain.github.io/Koconut/) supports dark mode theme. -
- -## Release **v1.0.15** - -
-1 Oct 2020 -
- -### Major Features and Improvements - -- New base container class `KoconutBoolean` is added. It is a child class that extends `KoconutPrimitive` and also implements `Boolean` of typescript. All the methods of other classes that return `KoconutPrimitive` are replcaed with it. Documentization is still being processed. Supported methods are as following. - - - `compareTo` - - `not` - - `and` - - `nand` - - `or` - - `nor` - - `xor` - - `xnor` - - `eqv` - -- New processor method `retrieve` is added to container classes. It simply processes all the chained objects and returns container instance itself. Please, have a check following example. - - ```typescript - const koconutBoolean = await new KoconutBoolean(true).retrieve(); - console.log(koconutBoolean); - // ↑ KoconutBoolean { isValidated: true, data: true } - ``` - -- Return type of `equalsTo` of protocol `KoconutEquatable` is now also can be `KoconutPrimitive` or `KoconutBoolean`. - -### Known Caveats - -- Following methods are deprecated. - - - `toArray` -- Commonly // `asArray` instead. - - `toSet` -- Commonly // `asSet` instead. - - `forEachIndexed` -- in `KoconutMap` - - `onEachIndexed` -- in `KoconutMap` - -
-
-
-
- -## Release **v1.0.14** - -
-21 Sep 2020 -
- -### Major Features and Improvements - -- New static creator method `generate` is added to container classes. It creates a new container instance with given `count` as number of elements and the values are provided by following `generator` function block with given ordered index as an argument . Please, have a check following example. - - ```typescript - const evenNumberArray = await KoconutArray.generate(5, (i) => i * 2).yield(); - console.log(evenNumberArray); - // ↑ [ 0, 2, 4, 6, 8 ] - - const evenNumberSet = await KoconutSet.generate(5, (i) => i * 2).yield(); - console.log(evenNumberSet); - // ↑ Set { 0, 2, 4, 6, 8 } - - const numberKeyStringValueMap = await KoconutMap.generate( - 5, - (i) => [i, i.toString()], - // ↑ Also can be - // new Pair(i, i.toString()) - // Pair.from([i, i.toString()]) - // new KoconutPair(i, i.toString()) - // new Entry(i, i.toString()) - // Entry.from([i, i.toString()]) - // new KoconutEntry(i, i.toString()) - ).yield(); - console.log(numberKeyStringValueMap); - // ↑ Map { 0 => '0', 1 => '1', 2 => '2', 3 => '3', 4 => '4' } - ``` - -### Bug Fixes and Other Changes - -- Mapping and filtering methods of collections with specified target destination is now propery applied to `Set` when the value is instance of - your custom class that inherits `KoconutEquatable`. - Applied Methods - `flatMapTo` - `mapTo` - `mapNotNullTo` - `flatMapIndexedTo` - `mapIndexedTo` - `mapIndexedNotNullTo` - `filterTo` - `filterNotTo` - `filterIndexedTo` - `filterNotNullTo` -
-
-
-
- -## Release **v1.0.13** - -
-18 Sep 2020 -
- -### Currently Working on... - -- I'm planning to design 2 new data container classes for sequential and parallel promise chain. Those are quite similar to `Sequence` or `Stream` in `Java` and `Kotlin`. - -### Known Caveats - -- `indexed` methods of `KoconutMap` are deprecated. It is not appropriate to let it be possible to use in `Map` data structure. They'll remain until version `1.0.15`. -- Common caster methods `toArray` and `toSet` are deprecated. Instead, you can use `asArray` or `asSet`. Those have the same functionality. They'll remain until version `1.0.15`. - -### Repository - -- API documentation of `KoconutMap` is completed. -
-
-
-
- -## Release **v1.0.12** - -
-14 Sep 2020 -
- -### Bug Fixes and Other Changes - -- Babel@runtime is now moved to common dependencies section. I'm sorry I didn't catch that. -
-
-
-
- -## Release **v1.0.11** - -
-12 Sep 2020 -
- -### Bug Fixes and Other Changes - -- Creation of container classes allows `null` as its argument and also use it as default value. When it is omitted, it'll return an empty collection instance. - - ```typescript - new KoconutArray(); - KoconutArray.of(); - KoconutArray.from(); // An empty array. - - new KoconutSet(); - KoconutSet.of(); - KoconutSet.from(); // An empty set. - - new KoconutMap(); - KcoonutMap.of(); - KoconutMap.from(); // An empty map. - ``` - - If you're using TypeScript, it is recommended to declare generic type explicitly. - -### Repository - -- README for NPM is now separated. Not very different from the original [README.md]. Since the column on NPM README is quite narrow and table of contents navigation does not work properly. I think it's because anchor links are generated differently on GitHub and NPM. I'll only leave brief introductions and examples in the NPM README. -
-
-
-
- -## Release **v1.0.10** - -
-10 Sep 2020 -
- -### Major Features and Improvements - -- Iterative functions, such as `forEach`, `forEachIndexed`, `onEach` and `onEachIndexed` now can be interrupted with `KoconutLoopSignal.BREAK`. Of course it is still available by simple `boolean`. To stop the iteration in the mean time, you can simply `return false` or `return KoconutLoopSignal.BREAK`. You can check [example](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#forEach) if you want to. - -### Known Caveats - -- [Deprecation Warning](https://github.com/ApexCaptain/Koconut/blob/master/README.md#Deprecation-Warning) functionality is now available - -### Repository - -- [README.md] and [CHANGELOG.md] files added. -- All the classes, methods, protocols or etc are currently being documentized and available from now on. There are still lots of work to do though... You can check'em [here](https://apexcaptain.github.io/Koconut/). - -[readme.md]: https://github.com/ApexCaptain/Koconut/blob/master/README.md -[changelog.md]: https://github.com/ApexCaptain/Koconut/blob/master/CHANGELOG.md +# Koconut Release Note + +## Release **v1.0.163** + +
+13 Dec 2021 +
+ +### Buf Fixes and Other Changes + +- Fix misspelled words in descriptive comments. + +### Known Caveats + +- Fix misspelled methods. + - Rename `mapVaues` to `mapValues` of [KoconutMap](https://apexcaptain.github.io/Koconut/classes/KoconutMap.html#mapValues). + - Rename `substract` to `subtract` of [KoconutCollection]. + - Rename `runningFoldindexed` to `runningFoldIndexed` of [KoconutCollection](https://apexcaptain.github.io/Koconut/classes/Reference.KoconutCollection.html#runningFoldIndexed). + +
+
+
+
+ +## Release **v1.0.162** + +
+8 Dec 2021 +
+ +### Bug Fixes and Other Changes + +- Fix some methods that did not print out intelliSence description of method example source. + +### Known Caveats + +- Changed the minimum Node.js version from 7 to 12 in order to follow [node.js release and maintenance policy](https://nodejs.org/en/about/releases/). + +### Repository + +- [API Document Page](https://apexcaptain.github.io/Koconut/) supports dark mode theme. +
+ +
+
+
+
+ +## Release **v1.0.15** + +
+1 Oct 2020 +
+ +### Major Features and Improvements + +- New base container class `KoconutBoolean` is added. It is a child class that extends `KoconutPrimitive` and also implements `Boolean` of typescript. All the methods of other classes that return `KoconutPrimitive` are replcaed with it. Documentization is still being processed. Supported methods are as following. + + - `compareTo` + - `not` + - `and` + - `nand` + - `or` + - `nor` + - `xor` + - `xnor` + - `eqv` + +- New processor method `retrieve` is added to container classes. It simply processes all the chained objects and returns container instance itself. Please, have a check following example. + + ```typescript + const koconutBoolean = await new KoconutBoolean(true).retrieve(); + console.log(koconutBoolean); + // ↑ KoconutBoolean { isValidated: true, data: true } + ``` + +- Return type of `equalsTo` of protocol `KoconutEquatable` is now also can be `KoconutPrimitive` or `KoconutBoolean`. + +### Known Caveats + +- Following methods are deprecated. + + - `toArray` -- Commonly // `asArray` instead. + - `toSet` -- Commonly // `asSet` instead. + - `forEachIndexed` -- in `KoconutMap` + - `onEachIndexed` -- in `KoconutMap` + +
+
+
+
+ +## Release **v1.0.14** + +
+21 Sep 2020 +
+ +### Major Features and Improvements + +- New static creator method `generate` is added to container classes. It creates a new container instance with given `count` as number of elements and the values are provided by following `generator` function block with given ordered index as an argument . Please, have a check following example. + + ```typescript + const evenNumberArray = await KoconutArray.generate(5, (i) => i * 2).yield(); + console.log(evenNumberArray); + // ↑ [ 0, 2, 4, 6, 8 ] + + const evenNumberSet = await KoconutSet.generate(5, (i) => i * 2).yield(); + console.log(evenNumberSet); + // ↑ Set { 0, 2, 4, 6, 8 } + + const numberKeyStringValueMap = await KoconutMap.generate( + 5, + (i) => [i, i.toString()], + // ↑ Also can be + // new Pair(i, i.toString()) + // Pair.from([i, i.toString()]) + // new KoconutPair(i, i.toString()) + // new Entry(i, i.toString()) + // Entry.from([i, i.toString()]) + // new KoconutEntry(i, i.toString()) + ).yield(); + console.log(numberKeyStringValueMap); + // ↑ Map { 0 => '0', 1 => '1', 2 => '2', 3 => '3', 4 => '4' } + ``` + +### Bug Fixes and Other Changes + +- Mapping and filtering methods of collections with specified target destination is now propery applied to `Set` when the value is instance of + your custom class that inherits `KoconutEquatable`. + Applied Methods - `flatMapTo` - `mapTo` - `mapNotNullTo` - `flatMapIndexedTo` - `mapIndexedTo` - `mapIndexedNotNullTo` - `filterTo` - `filterNotTo` - `filterIndexedTo` - `filterNotNullTo` + +
+
+
+
+ +## Release **v1.0.13** + +
+18 Sep 2020 +
+ +### Currently Working on... + +- I'm planning to design 2 new data container classes for sequential and parallel promise chain. Those are quite similar to `Sequence` or `Stream` in `Java` and `Kotlin`. + +### Known Caveats + +- `indexed` methods of `KoconutMap` are deprecated. It is not appropriate to let it be possible to use in `Map` data structure. They'll remain until version `1.0.15`. +- Common caster methods `toArray` and `toSet` are deprecated. Instead, you can use `asArray` or `asSet`. Those have the same functionality. They'll remain until version `1.0.15`. + +### Repository + +- API documentation of `KoconutMap` is completed. + +
+
+
+
+ +## Release **v1.0.12** + +
+14 Sep 2020 +
+ +### Bug Fixes and Other Changes + +- Babel@runtime is now moved to common dependencies section. I'm sorry I didn't catch that. + +
+
+
+
+ +## Release **v1.0.11** + +
+12 Sep 2020 +
+ +### Bug Fixes and Other Changes + +- Creation of container classes allows `null` as its argument and also use it as default value. When it is omitted, it'll return an empty collection instance. + + ```typescript + new KoconutArray(); + KoconutArray.of(); + KoconutArray.from(); // An empty array. + + new KoconutSet(); + KoconutSet.of(); + KoconutSet.from(); // An empty set. + + new KoconutMap(); + KcoonutMap.of(); + KoconutMap.from(); // An empty map. + ``` + + If you're using TypeScript, it is recommended to declare generic type explicitly. + +### Repository + +- README for NPM is now separated. Not very different from the original [README.md]. Since the column on NPM README is quite narrow and table of contents navigation does not work properly. I think it's because anchor links are generated differently on GitHub and NPM. I'll only leave brief introductions and examples in the NPM README. + +
+
+
+
+ +## Release **v1.0.10** + +
+10 Sep 2020 +
+ +### Major Features and Improvements + +- Iterative functions, such as `forEach`, `forEachIndexed`, `onEach` and `onEachIndexed` now can be interrupted with `KoconutLoopSignal.BREAK`. Of course it is still available by simple `boolean`. To stop the iteration in the mean time, you can simply `return false` or `return KoconutLoopSignal.BREAK`. You can check [example](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#forEach) if you want to. + +### Known Caveats + +- [Deprecation Warning](https://github.com/ApexCaptain/Koconut/blob/master/README.md#Deprecation-Warning) functionality is now available + +### Repository + +- [README.md] and [CHANGELOG.md] files added. +- All the classes, methods, protocols or etc are currently being documentized and available from now on. There are still lots of work to do though... You can check'em [here](https://apexcaptain.github.io/Koconut/). + +[readme.md]: https://github.com/ApexCaptain/Koconut/blob/master/README.md +[changelog.md]: https://github.com/ApexCaptain/Koconut/blob/master/CHANGELOG.md diff --git a/LICENSE b/LICENSE index 29f81d8..261eeb9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,201 +1,201 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 9a32214..30eb660 100644 --- a/README.md +++ b/README.md @@ -1,678 +1,678 @@ -# Koconut LogoKoconut : Kotlin Style Collection Lib For Node.Js - - - -[![npm version][npm-image]][npm-url] -[![Node.js CI][ci-image]][ci-url] -[![CodeQL][code-ql-image]][code-ql-url] -[![License][license-image]][license-url] -[![Node.js Version][node-version-image]][node-version-url] - -# Table of Contents - -- [Installation](#Installation) -- [Introduction](#Introduction) -- [Components](#Components) -- [Necessity](#Necessity) -- [Examples](#Examples) -- [Deprecation Warning](#Deprecation-Warning) -- [License](#License) - -# Installation - -This is a [Node.js](https://nodejs.org/en/) library available through the [npm registry](https://www.npmjs.com/). - -To install this lib you may use either `npm` or `yarn` command. - -```sh -npm install koconut --save - -# or - -yarn add koconut -``` - -But before that, please have a check whether [Node.js is correctly installed](https://nodejs.org/en/download/) into your dev env. - -# Introduction - -This is a node.js library for collection(a.k.a data structure). It's fully written in TypeScript, but also compatible with JavaScript application. It's 100% [Apache-2.0](https://github.com/ApexCaptain/Koconut/blob/master/LICENSE) licensed. - -Here is a short example on how to use it: - -### TypeScript - -```ts -import { KoconutArray } from "koconut"; - -const sampleProcess = async () => { - const myArray = KoconutArray.of(1, 2, 3, 4, 5, 6); - - const evenNumbers = await myArray - .filter((eachNumber) => eachNumber % 2 == 0) - .yield(); - - console.log(evenNumbers); - // ↑ [ 2, 4, 6 ] -}; -sampleProcess(); -``` - -### JavaScript (CommonJs) - -```js -const { KoconutArray } = require("koconut"); - -const sampleProcess = async () => { - const myArray = KoconutArray.of(1, 2, 3, 4, 5, 6); - - const evenNumbers = await myArray - .filter((eachNumber) => eachNumber % 2 == 0) - .yield(); - - console.log(evenNumbers); - // ↑ [ 2, 4, 6 ] -}; -sampleProcess(); -``` - -As you can see, there's no big difference between using it in JS and TS. Both examples created a 1 to 6 integer array and filtered only the even numbers. - -# Components - -## Documents - -The full document of this library is running on [git-hub page]. - -### Container - -- [KoconutEntry] -- [Entry] -- [KoconutPair] -- [Pair] -- [KoconutArray] -- [KoconutSet] -- [KoconutMap] - -### Enum - -- [KoconutLocale] -- [KoconutLoopSignal] - -### Exception - -- [KoconutConflictException] -- [KoconutIndexOutOfBoundsException] -- [KoconutInvalidArgumentException] -- [KoconutNoSuchElementException] - -### Protocol (Interface) - -- [KoconutComparable] -- [KoconutEquatable] - -### Tool - -- [KoconutOption] - -## Hierarchy - -This is the [Koconut] class hierarchy in current version. - -![Hierarchy](res/Hierarchy.png) - -# Necessity - -`OK, so... why do I need it?` - -[Koconut] is promise-friendly. The basic design philsophy of this library is to use `async/await` functionality without any interruption even if whlie using iterative process. Let me give you an example. - -Imagine if there are 3 different http requests info. Each and every one of them has a very different purpose and cannot be merged into a single requset. You may want to handle them one by one sequentially. - -```ts -const requestInfoList = [ - { - method: "POST", - uri: "https://myServer", - data: { - some: "payload1", - }, - }, - { - method: "GET", - uri: "https://myServer", - data: { - some: "payload2", - }, - }, - { - method: "DELETE", - uri: "https://myServer", - data: { - some: "payload3", - }, - }, -]; -``` - -Now, let's send those requests with one of the most common http node.js lib, [axios](https://www.npmjs.com/package/axios). - -```ts -const mainProcess = async () => { - const results = new Array(); - requestInfoList.forEach(async (eachRequestInfo) => { - const eachResult = await axios(eachRequestInfo); - results.push(eachResult); - }); - - console.log(results); // --- [1] : Empty List - console.log("Nailed it!"); -}; -mainProcess(); -``` - -Within upper example, each http request is handled asynchronously. However, the result of outer `forEach` function of normal `Array` is not a [Promise] instance, in other words, it does not support [Promise] nor `async/await`. - -Therefore, printed message at [1] is gonna be an empty list. This is definitely not what you've intended. - -Now, you have to come up with a different way. Maybe, after some Googling and Googling (Like as I did), you'll find an answer just like below. - -```ts -const mainProcess = async () => { - const results = new Array(); - for (const eachRequestInfo of requestInfoList) { - const eachResult = await axios(eachRequestInfo); - results.push(eachResult); - } - - console.log(results); // --- [1] : [ result1, result2, result3 ] - console.log("Nailed it!"); -}; -mainProcess(); -``` - -By doing this, all the requests are sent one by one. Printed message at [1] would be an array of three request results. - -The problem is resolved! Having a nice cuppa tea, reclining your seat, wow, you may leave work early today! - -Or... is it? - -The next day, your boss told you that each request result should be checked whether it's valid or not. - -The information you need is all in some other database. So, you made another `async` function called `checkIsValid`. - -Easy! It can be done like this. - -```ts -const mainProcess = async () => { - const results = new Array(); - for (const eachRequestInfo of requestInfoList) { - const eachResult = await axios(eachRequesInfo); - results.push(eachResult); - } - - const validResults = new Array(); - for (const eachResult of results) { - if (await checkIsValid(eachResult)) validResults.push(eachResult); - } - - console.log(validResults); // --- [1] : Valid results matches the given condition - console.log("Nailed it!"); -}; -mainProcess(); -``` - -Now you have two different arrays. This is the problem. Since previous iterable classes don't support [Promise], you have to keep adding `for...of` or `for...in` statement over and over again into your source code. As time goes by and your software becomes more and more complicated, your data processing would be messy and unrecognizable. - -It would be great just if you can use `filter` function instead, right? - -Well, here's an example using [KoconutArray]. - -```ts -import { KoconutArray } from "koconut"; -const mainProcess = async () => { - const validResults = await KoconutArray.from(requestInfoList) - .map(axios) - .filter(checkIsValid) - .yield(); - - console.log(validresults); - console.log("Nailed it!"); -}; -mainProcess(); -``` - -Boom! It is done! No more complicated `for...of` or `for...in` iterative processes. It is safe and quite beautiful. -Of course, I know that it's pretty unnatural example. You could fetch result and validate it simultaneously just in one loop. -But by drawing upon [Koconut] library, your source code would be much more clear and efficient. - -# Examples - -Let me give you a few examples for basic usage of this library. -I've written only about [KoconutArray] as a representative class. - -## Creation - -To create a [KoconutArray] instance, you can do it in 4 different ways. - -1. Using `new` keyword. - - Very traditional way. You can create a new instance from an iterable object or if it's ommitted you may have an empty array. In case of that, you'd better declare generic type explicitly. - - ```typescript - import { KoconutArray } from "koconut"; - - const emptyKoconutNumbers = new KoconutArray(); - // ↑ This is an empty Koconut number array - - const numbers = Array.of(1, 2, 3, 4, 5); - const koconuntNumbers = new KoconutArray(numbers); - // ↑ This is a Koconut number array consists of 1 to 5. - ``` - -2. Using `static` [from](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#from) method. - - You can create a new instance from an iterable object. - - ```typescript - import { KoconutArray } from "koconut"; - - 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. - ``` - -3. Using `static` [of](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#of) method. - - You can create a new instance with a variable number of arguments - - ```typescript - import { KoconutArray } from "koconut"; - - const koconutNumbers = KoconutArray.of(1, 2, 3, 4, 5); - // ↑ This is a Koconut number array consists of 1 to 5. - ``` - -4. Using `static` [generate](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#generate) method. - - This method creates a new instance with length positions and fills it with values provided by `generator` function callback with each index in the range "`0...length - 1`" in increasing order as an argument. Given `count` must be non-negative number. - - ```typescript - import { KoconutArray } from "koconut"; - - const evenNumberArray = await KoconutArray.generate(5, (i) => i * 2); - // ↑ This is a Koconut number array consists of 2, 4, 6, 8 and 10. - - const negativeLength = await KoconutArray.generate(-1, (i) => i * 2); - // ↑ This will cause invalid argument exception since given count is a negative number. - ``` - -## Processing - -All the [Koconut] containers internally connected with each other within [Promise] chain. In a nutshell, you have to process all the chained objects before you get the result. There are 3 ways to do that. They're almost same but slightly different. - -1. Using [yield](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#yield) method. - - This method processes all the chained objects and returns the result. - - ```typescript - 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(); - ``` - -2. Using [process](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#process) method. - - This method just simply processes all the chained objects, then return `Promise`. - - ```typescript - 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(); - ``` - -3. Using [let](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#let) method. - - This method processes all the chained objects and calls the specified function `block` with the reuslt value as its argument and returns the final result of the `block`. - - ```typescript - import { KoconutArray } from "koconut"; - - const mainProcess = async () => { - const koconutNumbers = KoconutArray.of(1, 2, 3, 4, 5); - - const firstNumberPlus2 = await koconutNumbers - .first() - .let((result) => result + 2); - console.log(firstNumber); - // ↑ 3 - }; - mainProcess(); - ``` - -4. Using [also](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#also) method. - - This method processes all the chained objects and calls the specified function `block` with the result value as its argument and return passed result object. - - ```typescript - import { KoconutArray } from "koconut"; - - const mainProcess = async () => { - const koconutNumbers = KoconutArray.of(1, 2, 3, 4, 5); - - const moreNumbers = await koconutNumbers.also((result) => { - result.push(6); - result.push(7); - result.push(8); - }); - console.log(moreNumbers); - // ↑ [1, 2, 3, 4, 5, 6, 7, 8] - }; - mainProcess(); - ``` - -## Iteration - -Iterative methods of [KoconutArray] are [forEach](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#forEach), [forEachIndexed](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#forEachIndexed), [onEach](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#onEach) and [onEachIndexed](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#onEachIndexed). These methods loop to repeat given `action`. - -Methods of which names start with `for` return nothing. - -Methods start with `on` return the original collection itself. - -```typescript -import { KoconutArray } from "koconut"; - -const mainProcess = async () => { - const koconutNumbers = KoconutArray.of(1, 2, 3, 4, 5); - - const resultOfForEach = await koconutNumbers - .forEach(console.log) - // ↑ 1 2 3 4 5 - .yield(); - console.log(resultOfForEach); - // ↑ undefined - - const resultOfOnEach = await koconutNumbers - .onEach(console.log) - // ↑ 1 2 3 4 5 - .yield(); - console.log(resultOfForEach); - // ↑ [1, 2, 3, 4, 5] -}; -mainProcess(); -``` - -And of course, methods of which name end with `indexed` have action block given with two arguments. - -One is index, and the other is element. - -If you want to interrupt, in other word `stop` the iteration process in the meantime, you may return `false` or [KoconutLoopSignal.BREAK](https://apexcaptain.github.io/Koconut/enums/KoconutLoopSignal.html#BREAK). - -## Calculation - -Each calculator method has its own purpose, performing calculation according to the established rules. For instance, [maxBy] method returns the first element yielding the largest value of the given function block. - -```typescript -import { KoconutArray } from "koconut"; - -const mainProcess = async () => { - const koconutArray = KoconutArray.of(1, 2, 3, 4, 5); - - const largestNumberOfArray = await koconutArray - .maxBy((eachNumber) => eachNumber) - .yield(); - console.log(largestNumberOfArray); - // ↑ 5 - - try { - await koconutArray - .filter((eachNumber) => eachNumber > 10) - .maxBy((eachNumber) => eachNumber) - .yield(); - } catch (error) { - console.log(error.name); - // ↑ Koconut No Such Element Exception - // i.e. -- Array is filtered. - // No element in 1 to 5 is greater than 10. - } -}; -mainProcess(); -``` - -## Manipulation - -Manipulator methods rearrange the collection, add new elements or filter it by given condition. For instance, [sortedBy](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#sortedBy) method returns a collection of all elements sorted according to natural sort order(ASC) of the value returned by specified `selector` function block. - -```typescript -import { KoconutArray } from "koconut"; - -const mainProcess = async () => { - const koconutArray = KoconutArray.of("abcd", "ab", "abc", "a"); - - const sortedStringArrayByLength = await koconutArray - .sortedBy((eachString) => eachString.length) - .yield(); - console.log(sortedStringArrayByLength); - // ↑ [ 'a', 'ab', 'abc', 'abcd' ] -}; -mainProcess(); -``` - -## Inspection - -Inspector methods check the elements at given condtion. For instance, [all](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#all) method return `true` if all elements match the given `predicate` function block. If any one of those elements doesn't meet the condtion, it'll return `false`. - -```typescript -import { KoconutArray } from "koconut"; - -const mainProcess = async () => { - 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. -}; -mainProcess(); -``` - -## Transformation - -Transformer methods convert the collection into other format. The [map](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#map) method is representative. It returns a list containing the results of applying the given `transform` function block to each element in the original collection. - -```typescript -import { KoconutArray } from "koconut"; - -const mainProcess = async () => { - const koconutArray = KoconutArray.of(1, 2, 3, 4, 5); - - const dobuledNumbers = await koconutArray - .map((eachNumber) => eachNumber * 2) - .yield(); - console.log(dobuledNumbers); - // ↑ [ 2, 4, 6, 8, 10 ] - - const numberStrings = await koconutArray - .map((eachNumber) => eachNumber.toString()) - .yield(); - console.log(numberStrings); - // ↑ [ '1', '2', '3', '4', '5' ] -}; -mainProcess(); -``` - -# Deprecation Warning - -## Introduction - -Some methods might no longer be supported in the future. If you have used any one of them, your application is gonna be crashed after updating the library with no reason. To prevent such troubles, [Koconut] supports `Deprecation Warning` functionality since version [1.0.10](./CHANGELOG.md#Release-1.0.10). - -What does that mean? - -## Example - -For instance, [maxBy] method in [KoconutArray] returns the first element yielding the largest value of the given function or throw [KoconutNoSuchElementException] when there is no element. Following examples are same as written in document page. - -```typescript -import { KoconutArray } from "koconut"; - -const main = async () => { - // Create an 1 to 5 number array. - const koconutArray = KoconutArray.of(1, 2, 3, 4, 5); - - // 1st example. Finding largest number. - const largestNumberOfArray = await koconutArray - .maxBy((eachNumber) => eachNumber) - .yield(); - console.log(largestNumberOfArray); - // ↑ 5 - - // 2nd example. Finding largest number of an empty array. - try { - await koconutArray - .filter((eachNumber) => eachNumber > 10) // <-- Now, it's empty - .maxBy((eachNumber) => eachNumber) // <-- This is impossible - .yield(); - } catch (error) { - console.log(error.name); - // ↑ Koconut No Such Element Exception - // i.e. -- Array is filtered. - // No element in 1 to 5 is greater than 10. - } -}; -main(); -``` - -The first example returns `5`, which is of course, the largest value of the array. - -However in the second one, [maxBy] method throws an error because you've just tried to get an `element` in an `empty array`. If this error had not been caught, the whole application would be termintaed. - -This is why [maxBy] method is depreacted, and also why usage of [maxByOrNull] method is recommended. It'll just return `null` if the array is empty. - -The problem is that you might not have known about it. You must be warned before that happens and that's where the `Deprecation Warning` comes in. When you use a method that is gonna be depreacted someday, [Koconut] will notice you that `"Oh, this method is not supported any more. You'd better use this one instead."`. - -## Language Support - -Currently, `Deprecation Warning` of [Koconut] supports three languages. -![languageSupportExample](res/deprecationWarning/languageSupportExample.png) - -Locale setting is done automatically. If you are in Japan, message will be printed in Japanese. If you are in Korea it'll be Korean or if you're in States, English will be your default locale. - -If you want more detail, please have a check [here](https://apexcaptain.github.io/Koconut/enums/KoconutLocale.html). - -## [Options](https://apexcaptain.github.io/Koconut/classes/KoconutOption.html) - -There are three options you can change for `Depreation Warning`. - -- [Locale](https://apexcaptain.github.io/Koconut/enums/KoconutLocale.html) - - You can chagne the language explicitly. Default value depends on your actual region. If it's not supported, `en(English)` will be the default. For instance, if you're in China or Russia, default locale is just `English`. I'm sorry I cannot handle them all... - - ```typescript - import { KoconutOption, KoconutLocale } from "koconut"; - - KoconutOption.locale = KoconutLocale.en; // English - KoconutOption.locale = KoconutLocale.ja; // Japanese - KoconutOption.locale = KoconutLocale.ko; // Korean - ``` - -- Availability - - Simply, if you don't want to use `Depreaction Warning` set the flag to `false`. Default value is `true`. - - ```typescript - import { KoconutOption } from "koconut"; - - KoconutOption.isDeprecationWarningEnabled = true; // Enabled (Default) - KoconutOption.isDeprecationWarningEnabled = false; // Disabled - ``` - -- Call Stack - - If you don't want to see messy call stack of the warning, you just disable it by setting the flag to `false`. - - ```typescript - import { KoconutOption } from "koconut"; - - KoconutOption.doesDeprecationWarningShowCallStack = true; // Enabled (Default) - KoconutOption.doesDeprecationWarningShowCallStack = false; // Disabled - ``` - -# License - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - - - -[npm-image]: https://img.shields.io/npm/v/koconut.svg?color=CB0000&label=npm&style=plastic&logo=npm -[npm-url]: https://www.npmjs.com/package/koconut -[ci-image]: https://github.com/ApexCaptain/Koconut/actions/workflows/pipeline.yml/badge.svg -[ci-url]: https://github.com/ApexCaptain/Koconut/actions/workflows/pipeline.yml -[code-ql-image]: https://github.com/ApexCaptain/Koconut/actions/workflows/codeql.yml/badge.svg?branch=master -[code-ql-url]: https://github.com/ApexCaptain/Koconut/actions/workflows/codeql.yml -[license-image]: https://img.shields.io/github/license/ApexCaptain/Koconut.svg?color=E2AC00&label=License&style=plastic&logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8%2F9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAdgAAAHYBTnsmCAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAHSSURBVDiNpZLLa1NREMa%2FmXvzaG2lKDW2EdNqi6Ckxq5Kdy0UsnQTs1CrWxcidFPEnYumG%2FFfUHRloC5cBTU%2Bdi6Cr1QUYh9wqS3RWmqoNzf3zrgIN2DahkK%2B1Zw5v%2Flm5nCANkV%2BoC%2BiR6uQayHXeEBJa9N%2BdWKIHO85AGjQmApPWKVm5j%2BDWr5vxv1m3OOIQioE7hZImQEA3CuQP1zPrTOMM95McPLHfQBg32BuYXQxtxMtzOcTyY5pi7SHh7nfs7nfs%2FWwO9QxbdH8ywvJ3E60kFkY%2FeLXmX6wuNYzVdzoHFcJ3QWQC09YpUom9g4Aum6vft%2BLaUyQSl0dhKKUzWYdgqymL6ZPA0DgXC3uN9iPqa%2FgynU1nccAYDtdDz02rtSfmBor7sdQ9U0k%2Fmkpcicx8PO9z35YOZIYOVWew7b5tlY0PwbG7ZvF5d7Zkdjm52bGJJfHzsfKaVWkZYPhrRg4i22IBB0%2BJvVBXB6Ln%2Fx1WRXYxQQ49IgITwGq6V8CSEHdshZm45bf7SDMnqo%2Bi%2F6uZGKvWzHc6vIgatuAmhPV%2FPFLTDwIALKFlG7RkjGgBQAQleXQ5PqTlgZOvq8C4JB%2F9r42PiuU1Ou8YZnNNW3pH9Tv3ULkpzpnAAAAAElFTkSuQmCC -[license-url]: https://github.com/ApexCaptain/Koconut/blob/master/LICENSE -[node-version-image]: http://img.shields.io/node/v/koconut.svg?style=plastic&color=378C37&label=Node.js&logo=node.js -[node-version-url]: https://nodejs.org/download/ - - - -[koconut]: https://github.com/ApexCaptain/Koconut -[git-hub page]: https://apexcaptain.github.io/Koconut/ - - - -[koconutentry]: https://apexcaptain.github.io/Koconut/classes/KoconutEntry.html -[entry]: https://apexcaptain.github.io/Koconut/classes/Entry.html -[koconutpair]: https://apexcaptain.github.io/Koconut/classes/KoconutPair.html -[pair]: https://apexcaptain.github.io/Koconut/classes/Pair.html -[koconutarray]: https://apexcaptain.github.io/Koconut/classes/KoconutArray.html -[koconutset]: https://apexcaptain.github.io/Koconut/classes/KoconutSet.html -[koconutmap]: https://apexcaptain.github.io/Koconut/classes/KoconutMap.html -[koconutlocale]: https://apexcaptain.github.io/Koconut/enums/KoconutLocale.html -[koconutloopsignal]: https://apexcaptain.github.io/Koconut/enums/KoconutLoopSignal.html -[koconutconflictexception]: https://apexcaptain.github.io/Koconut/classes/KoconutConflictException.html -[koconutindexoutofboundsexception]: https://apexcaptain.github.io/Koconut/classes/KoconutIndexOutOfBoundsException.html -[koconutinvalidargumentexception]: https://apexcaptain.github.io/Koconut/classes/KoconutInvalidArgumentException.html -[koconutnosuchelementexception]: https://apexcaptain.github.io/Koconut/classes/KoconutNoSuchElementException.html -[koconutcomparable]: https://apexcaptain.github.io/Koconut/interfaces/KoconutComparable.html -[koconutequatable]: https://apexcaptain.github.io/Koconut/interfaces/KoconutEquatable.html -[koconutoption]: https://apexcaptain.github.io/Koconut/classes/KoconutOption.html - - - -[promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise -[maxby]: https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#maxBy -[maxbyornull]: https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#maxByOrNull +# Koconut LogoKoconut : Kotlin Style Collection Lib For Node.Js + + + +[![npm version][npm-image]][npm-url] +[![Node.js CI][ci-image]][ci-url] +[![CodeQL][code-ql-image]][code-ql-url] +[![License][license-image]][license-url] +[![Node.js Version][node-version-image]][node-version-url] + +# Table of Contents + +- [Installation](#Installation) +- [Introduction](#Introduction) +- [Components](#Components) +- [Necessity](#Necessity) +- [Examples](#Examples) +- [Deprecation Warning](#Deprecation-Warning) +- [License](#License) + +# Installation + +This is a [Node.js](https://nodejs.org/en/) library available through the [npm registry](https://www.npmjs.com/). + +To install this lib you may use either `npm` or `yarn` command. + +```sh +npm install koconut --save + +# or + +yarn add koconut +``` + +But before that, please have a check whether [Node.js is correctly installed](https://nodejs.org/en/download/) into your dev env. + +# Introduction + +This is a node.js library for collection(a.k.a data structure). It's fully written in TypeScript, but also compatible with JavaScript application. It's 100% [Apache-2.0](https://github.com/ApexCaptain/Koconut/blob/master/LICENSE) licensed. + +Here is a short example on how to use it: + +### TypeScript + +```ts +import { KoconutArray } from 'koconut'; + +const sampleProcess = async () => { + const myArray = KoconutArray.of(1, 2, 3, 4, 5, 6); + + const evenNumbers = await myArray + .filter((eachNumber) => eachNumber % 2 == 0) + .yield(); + + console.log(evenNumbers); + // ↑ [ 2, 4, 6 ] +}; +sampleProcess(); +``` + +### JavaScript (CommonJs) + +```js +const { KoconutArray } = require('koconut'); + +const sampleProcess = async () => { + const myArray = KoconutArray.of(1, 2, 3, 4, 5, 6); + + const evenNumbers = await myArray + .filter((eachNumber) => eachNumber % 2 == 0) + .yield(); + + console.log(evenNumbers); + // ↑ [ 2, 4, 6 ] +}; +sampleProcess(); +``` + +As you can see, there's no big difference between using it in JS and TS. Both examples created a 1 to 6 integer array and filtered only the even numbers. + +# Components + +## Documents + +The full document of this library is running on [git-hub page]. + +### Container + +- [KoconutEntry] +- [Entry] +- [KoconutPair] +- [Pair] +- [KoconutArray] +- [KoconutSet] +- [KoconutMap] + +### Enum + +- [KoconutLocale] +- [KoconutLoopSignal] + +### Exception + +- [KoconutConflictException] +- [KoconutIndexOutOfBoundsException] +- [KoconutInvalidArgumentException] +- [KoconutNoSuchElementException] + +### Protocol (Interface) + +- [KoconutComparable] +- [KoconutEquatable] + +### Tool + +- [KoconutOption] + +## Hierarchy + +This is the [Koconut] class hierarchy in current version. + +![Hierarchy](res/Hierarchy.png) + +# Necessity + +`OK, so... why do I need it?` + +[Koconut] is promise-friendly. The basic design philsophy of this library is to use `async/await` functionality without any interruption even if whlie using iterative process. Let me give you an example. + +Imagine if there are 3 different http requests info. Each and every one of them has a very different purpose and cannot be merged into a single requset. You may want to handle them one by one sequentially. + +```ts +const requestInfoList = [ + { + method: 'POST', + uri: 'https://myServer', + data: { + some: 'payload1', + }, + }, + { + method: 'GET', + uri: 'https://myServer', + data: { + some: 'payload2', + }, + }, + { + method: 'DELETE', + uri: 'https://myServer', + data: { + some: 'payload3', + }, + }, +]; +``` + +Now, let's send those requests with one of the most common http node.js lib, [axios](https://www.npmjs.com/package/axios). + +```ts +const mainProcess = async () => { + const results = new Array(); + requestInfoList.forEach(async (eachRequestInfo) => { + const eachResult = await axios(eachRequestInfo); + results.push(eachResult); + }); + + console.log(results); // --- [1] : Empty List + console.log('Nailed it!'); +}; +mainProcess(); +``` + +Within upper example, each http request is handled asynchronously. However, the result of outer `forEach` function of normal `Array` is not a [Promise] instance, in other words, it does not support [Promise] nor `async/await`. + +Therefore, printed message at [1] is gonna be an empty list. This is definitely not what you've intended. + +Now, you have to come up with a different way. Maybe, after some Googling and Googling (Like as I did), you'll find an answer just like below. + +```ts +const mainProcess = async () => { + const results = new Array(); + for (const eachRequestInfo of requestInfoList) { + const eachResult = await axios(eachRequestInfo); + results.push(eachResult); + } + + console.log(results); // --- [1] : [ result1, result2, result3 ] + console.log('Nailed it!'); +}; +mainProcess(); +``` + +By doing this, all the requests are sent one by one. Printed message at [1] would be an array of three request results. + +The problem is resolved! Having a nice cuppa tea, reclining your seat, wow, you may leave work early today! + +Or... is it? + +The next day, your boss told you that each request result should be checked whether it's valid or not. + +The information you need is all in some other database. So, you made another `async` function called `checkIsValid`. + +Easy! It can be done like this. + +```ts +const mainProcess = async () => { + const results = new Array(); + for (const eachRequestInfo of requestInfoList) { + const eachResult = await axios(eachRequesInfo); + results.push(eachResult); + } + + const validResults = new Array(); + for (const eachResult of results) { + if (await checkIsValid(eachResult)) validResults.push(eachResult); + } + + console.log(validResults); // --- [1] : Valid results matches the given condition + console.log('Nailed it!'); +}; +mainProcess(); +``` + +Now you have two different arrays. This is the problem. Since previous iterable classes don't support [Promise], you have to keep adding `for...of` or `for...in` statement over and over again into your source code. As time goes by and your software becomes more and more complicated, your data processing would be messy and unrecognizable. + +It would be great just if you can use `filter` function instead, right? + +Well, here's an example using [KoconutArray]. + +```ts +import { KoconutArray } from 'koconut'; +const mainProcess = async () => { + const validResults = await KoconutArray.from(requestInfoList) + .map(axios) + .filter(checkIsValid) + .yield(); + + console.log(validresults); + console.log('Nailed it!'); +}; +mainProcess(); +``` + +Boom! It is done! No more complicated `for...of` or `for...in` iterative processes. It is safe and quite beautiful. +Of course, I know that it's pretty unnatural example. You could fetch result and validate it simultaneously just in one loop. +But by drawing upon [Koconut] library, your source code would be much more clear and efficient. + +# Examples + +Let me give you a few examples for basic usage of this library. +I've written only about [KoconutArray] as a representative class. + +## Creation + +To create a [KoconutArray] instance, you can do it in 4 different ways. + +1. Using `new` keyword. + + Very traditional way. You can create a new instance from an iterable object or if it's ommitted you may have an empty array. In case of that, you'd better declare generic type explicitly. + + ```typescript + import { KoconutArray } from 'koconut'; + + const emptyKoconutNumbers = new KoconutArray(); + // ↑ This is an empty Koconut number array + + const numbers = Array.of(1, 2, 3, 4, 5); + const koconuntNumbers = new KoconutArray(numbers); + // ↑ This is a Koconut number array consists of 1 to 5. + ``` + +2. Using `static` [from](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#from) method. + + You can create a new instance from an iterable object. + + ```typescript + import { KoconutArray } from 'koconut'; + + 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. + ``` + +3. Using `static` [of](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#of) method. + + You can create a new instance with a variable number of arguments + + ```typescript + import { KoconutArray } from 'koconut'; + + const koconutNumbers = KoconutArray.of(1, 2, 3, 4, 5); + // ↑ This is a Koconut number array consists of 1 to 5. + ``` + +4. Using `static` [generate](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#generate) method. + + This method creates a new instance with length positions and fills it with values provided by `generator` function callback with each index in the range "`0...length - 1`" in increasing order as an argument. Given `count` must be non-negative number. + + ```typescript + import { KoconutArray } from 'koconut'; + + const evenNumberArray = await KoconutArray.generate(5, (i) => i * 2); + // ↑ This is a Koconut number array consists of 2, 4, 6, 8 and 10. + + const negativeLength = await KoconutArray.generate(-1, (i) => i * 2); + // ↑ This will cause invalid argument exception since given count is a negative number. + ``` + +## Processing + +All the [Koconut] containers internally connected with each other within [Promise] chain. In a nutshell, you have to process all the chained objects before you get the result. There are 3 ways to do that. They're almost same but slightly different. + +1. Using [yield](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#yield) method. + + This method processes all the chained objects and returns the result. + + ```typescript + 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(); + ``` + +2. Using [process](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#process) method. + + This method just simply processes all the chained objects, then return `Promise`. + + ```typescript + 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(); + ``` + +3. Using [let](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#let) method. + + This method processes all the chained objects and calls the specified function `block` with the reuslt value as its argument and returns the final result of the `block`. + + ```typescript + import { KoconutArray } from 'koconut'; + + const mainProcess = async () => { + const koconutNumbers = KoconutArray.of(1, 2, 3, 4, 5); + + const firstNumberPlus2 = await koconutNumbers + .first() + .let((result) => result + 2); + console.log(firstNumber); + // ↑ 3 + }; + mainProcess(); + ``` + +4. Using [also](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#also) method. + + This method processes all the chained objects and calls the specified function `block` with the result value as its argument and return passed result object. + + ```typescript + import { KoconutArray } from 'koconut'; + + const mainProcess = async () => { + const koconutNumbers = KoconutArray.of(1, 2, 3, 4, 5); + + const moreNumbers = await koconutNumbers.also((result) => { + result.push(6); + result.push(7); + result.push(8); + }); + console.log(moreNumbers); + // ↑ [1, 2, 3, 4, 5, 6, 7, 8] + }; + mainProcess(); + ``` + +## Iteration + +Iterative methods of [KoconutArray] are [forEach](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#forEach), [forEachIndexed](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#forEachIndexed), [onEach](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#onEach) and [onEachIndexed](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#onEachIndexed). These methods loop to repeat given `action`. + +Methods of which names start with `for` return nothing. + +Methods start with `on` return the original collection itself. + +```typescript +import { KoconutArray } from 'koconut'; + +const mainProcess = async () => { + const koconutNumbers = KoconutArray.of(1, 2, 3, 4, 5); + + const resultOfForEach = await koconutNumbers + .forEach(console.log) + // ↑ 1 2 3 4 5 + .yield(); + console.log(resultOfForEach); + // ↑ undefined + + const resultOfOnEach = await koconutNumbers + .onEach(console.log) + // ↑ 1 2 3 4 5 + .yield(); + console.log(resultOfForEach); + // ↑ [1, 2, 3, 4, 5] +}; +mainProcess(); +``` + +And of course, methods of which name end with `indexed` have action block given with two arguments. + +One is index, and the other is element. + +If you want to interrupt, in other word `stop` the iteration process in the meantime, you may return `false` or [KoconutLoopSignal.BREAK](https://apexcaptain.github.io/Koconut/enums/KoconutLoopSignal.html#BREAK). + +## Calculation + +Each calculator method has its own purpose, performing calculation according to the established rules. For instance, [maxBy] method returns the first element yielding the largest value of the given function block. + +```typescript +import { KoconutArray } from 'koconut'; + +const mainProcess = async () => { + const koconutArray = KoconutArray.of(1, 2, 3, 4, 5); + + const largestNumberOfArray = await koconutArray + .maxBy((eachNumber) => eachNumber) + .yield(); + console.log(largestNumberOfArray); + // ↑ 5 + + try { + await koconutArray + .filter((eachNumber) => eachNumber > 10) + .maxBy((eachNumber) => eachNumber) + .yield(); + } catch (error) { + console.log(error.name); + // ↑ Koconut No Such Element Exception + // i.e. -- Array is filtered. + // No element in 1 to 5 is greater than 10. + } +}; +mainProcess(); +``` + +## Manipulation + +Manipulator methods rearrange the collection, add new elements or filter it by given condition. For instance, [sortedBy](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#sortedBy) method returns a collection of all elements sorted according to natural sort order(ASC) of the value returned by specified `selector` function block. + +```typescript +import { KoconutArray } from 'koconut'; + +const mainProcess = async () => { + const koconutArray = KoconutArray.of('abcd', 'ab', 'abc', 'a'); + + const sortedStringArrayByLength = await koconutArray + .sortedBy((eachString) => eachString.length) + .yield(); + console.log(sortedStringArrayByLength); + // ↑ [ 'a', 'ab', 'abc', 'abcd' ] +}; +mainProcess(); +``` + +## Inspection + +Inspector methods check the elements at given condtion. For instance, [all](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#all) method return `true` if all elements match the given `predicate` function block. If any one of those elements doesn't meet the condtion, it'll return `false`. + +```typescript +import { KoconutArray } from 'koconut'; + +const mainProcess = async () => { + 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. +}; +mainProcess(); +``` + +## Transformation + +Transformer methods convert the collection into other format. The [map](https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#map) method is representative. It returns a list containing the results of applying the given `transform` function block to each element in the original collection. + +```typescript +import { KoconutArray } from 'koconut'; + +const mainProcess = async () => { + const koconutArray = KoconutArray.of(1, 2, 3, 4, 5); + + const dobuledNumbers = await koconutArray + .map((eachNumber) => eachNumber * 2) + .yield(); + console.log(dobuledNumbers); + // ↑ [ 2, 4, 6, 8, 10 ] + + const numberStrings = await koconutArray + .map((eachNumber) => eachNumber.toString()) + .yield(); + console.log(numberStrings); + // ↑ [ '1', '2', '3', '4', '5' ] +}; +mainProcess(); +``` + +# Deprecation Warning + +## Introduction + +Some methods might no longer be supported in the future. If you have used any one of them, your application is gonna be crashed after updating the library with no reason. To prevent such troubles, [Koconut] supports `Deprecation Warning` functionality since version [1.0.10](./CHANGELOG.md#Release-1.0.10). + +What does that mean? + +## Example + +For instance, [maxBy] method in [KoconutArray] returns the first element yielding the largest value of the given function or throw [KoconutNoSuchElementException] when there is no element. Following examples are same as written in document page. + +```typescript +import { KoconutArray } from 'koconut'; + +const main = async () => { + // Create an 1 to 5 number array. + const koconutArray = KoconutArray.of(1, 2, 3, 4, 5); + + // 1st example. Finding largest number. + const largestNumberOfArray = await koconutArray + .maxBy((eachNumber) => eachNumber) + .yield(); + console.log(largestNumberOfArray); + // ↑ 5 + + // 2nd example. Finding largest number of an empty array. + try { + await koconutArray + .filter((eachNumber) => eachNumber > 10) // <-- Now, it's empty + .maxBy((eachNumber) => eachNumber) // <-- This is impossible + .yield(); + } catch (error) { + console.log(error.name); + // ↑ Koconut No Such Element Exception + // i.e. -- Array is filtered. + // No element in 1 to 5 is greater than 10. + } +}; +main(); +``` + +The first example returns `5`, which is of course, the largest value of the array. + +However in the second one, [maxBy] method throws an error because you've just tried to get an `element` in an `empty array`. If this error had not been caught, the whole application would be termintaed. + +This is why [maxBy] method is depreacted, and also why usage of [maxByOrNull] method is recommended. It'll just return `null` if the array is empty. + +The problem is that you might not have known about it. You must be warned before that happens and that's where the `Deprecation Warning` comes in. When you use a method that is gonna be depreacted someday, [Koconut] will notice you that `"Oh, this method is not supported any more. You'd better use this one instead."`. + +## Language Support + +Currently, `Deprecation Warning` of [Koconut] supports three languages. +![languageSupportExample](res/deprecationWarning/languageSupportExample.png) + +Locale setting is done automatically. If you are in Japan, message will be printed in Japanese. If you are in Korea it'll be Korean or if you're in States, English will be your default locale. + +If you want more detail, please have a check [here](https://apexcaptain.github.io/Koconut/enums/KoconutLocale.html). + +## [Options](https://apexcaptain.github.io/Koconut/classes/KoconutOption.html) + +There are three options you can change for `Depreation Warning`. + +- [Locale](https://apexcaptain.github.io/Koconut/enums/KoconutLocale.html) + + You can chagne the language explicitly. Default value depends on your actual region. If it's not supported, `en(English)` will be the default. For instance, if you're in China or Russia, default locale is just `English`. I'm sorry I cannot handle them all... + + ```typescript + import { KoconutOption, KoconutLocale } from 'koconut'; + + KoconutOption.locale = KoconutLocale.en; // English + KoconutOption.locale = KoconutLocale.ja; // Japanese + KoconutOption.locale = KoconutLocale.ko; // Korean + ``` + +- Availability + + Simply, if you don't want to use `Depreaction Warning` set the flag to `false`. Default value is `true`. + + ```typescript + import { KoconutOption } from 'koconut'; + + KoconutOption.isDeprecationWarningEnabled = true; // Enabled (Default) + KoconutOption.isDeprecationWarningEnabled = false; // Disabled + ``` + +- Call Stack + + If you don't want to see messy call stack of the warning, you just disable it by setting the flag to `false`. + + ```typescript + import { KoconutOption } from 'koconut'; + + KoconutOption.doesDeprecationWarningShowCallStack = true; // Enabled (Default) + KoconutOption.doesDeprecationWarningShowCallStack = false; // Disabled + ``` + +# License + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + + + +[npm-image]: https://img.shields.io/npm/v/koconut.svg?color=CB0000&label=npm&style=plastic&logo=npm +[npm-url]: https://www.npmjs.com/package/koconut +[ci-image]: https://github.com/ApexCaptain/Koconut/actions/workflows/pipeline.yml/badge.svg +[ci-url]: https://github.com/ApexCaptain/Koconut/actions/workflows/pipeline.yml +[code-ql-image]: https://github.com/ApexCaptain/Koconut/actions/workflows/codeql.yml/badge.svg?branch=master +[code-ql-url]: https://github.com/ApexCaptain/Koconut/actions/workflows/codeql.yml +[license-image]: https://img.shields.io/github/license/ApexCaptain/Koconut.svg?color=E2AC00&label=License&style=plastic&logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8%2F9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAdgAAAHYBTnsmCAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAHSSURBVDiNpZLLa1NREMa%2FmXvzaG2lKDW2EdNqi6Ckxq5Kdy0UsnQTs1CrWxcidFPEnYumG%2FFfUHRloC5cBTU%2Bdi6Cr1QUYh9wqS3RWmqoNzf3zrgIN2DahkK%2B1Zw5v%2Flm5nCANkV%2BoC%2BiR6uQayHXeEBJa9N%2BdWKIHO85AGjQmApPWKVm5j%2BDWr5vxv1m3OOIQioE7hZImQEA3CuQP1zPrTOMM95McPLHfQBg32BuYXQxtxMtzOcTyY5pi7SHh7nfs7nfs%2FWwO9QxbdH8ywvJ3E60kFkY%2FeLXmX6wuNYzVdzoHFcJ3QWQC09YpUom9g4Aum6vft%2BLaUyQSl0dhKKUzWYdgqymL6ZPA0DgXC3uN9iPqa%2FgynU1nccAYDtdDz02rtSfmBor7sdQ9U0k%2Fmkpcicx8PO9z35YOZIYOVWew7b5tlY0PwbG7ZvF5d7Zkdjm52bGJJfHzsfKaVWkZYPhrRg4i22IBB0%2BJvVBXB6Ln%2Fx1WRXYxQQ49IgITwGq6V8CSEHdshZm45bf7SDMnqo%2Bi%2F6uZGKvWzHc6vIgatuAmhPV%2FPFLTDwIALKFlG7RkjGgBQAQleXQ5PqTlgZOvq8C4JB%2F9r42PiuU1Ou8YZnNNW3pH9Tv3ULkpzpnAAAAAElFTkSuQmCC +[license-url]: https://github.com/ApexCaptain/Koconut/blob/master/LICENSE +[node-version-image]: http://img.shields.io/node/v/koconut.svg?style=plastic&color=378C37&label=Node.js&logo=node.js +[node-version-url]: https://nodejs.org/download/ + + + +[koconut]: https://github.com/ApexCaptain/Koconut +[git-hub page]: https://apexcaptain.github.io/Koconut/ + + + +[koconutentry]: https://apexcaptain.github.io/Koconut/classes/KoconutEntry.html +[entry]: https://apexcaptain.github.io/Koconut/classes/Entry.html +[koconutpair]: https://apexcaptain.github.io/Koconut/classes/KoconutPair.html +[pair]: https://apexcaptain.github.io/Koconut/classes/Pair.html +[koconutarray]: https://apexcaptain.github.io/Koconut/classes/KoconutArray.html +[koconutset]: https://apexcaptain.github.io/Koconut/classes/KoconutSet.html +[koconutmap]: https://apexcaptain.github.io/Koconut/classes/KoconutMap.html +[koconutlocale]: https://apexcaptain.github.io/Koconut/enums/KoconutLocale.html +[koconutloopsignal]: https://apexcaptain.github.io/Koconut/enums/KoconutLoopSignal.html +[koconutconflictexception]: https://apexcaptain.github.io/Koconut/classes/KoconutConflictException.html +[koconutindexoutofboundsexception]: https://apexcaptain.github.io/Koconut/classes/KoconutIndexOutOfBoundsException.html +[koconutinvalidargumentexception]: https://apexcaptain.github.io/Koconut/classes/KoconutInvalidArgumentException.html +[koconutnosuchelementexception]: https://apexcaptain.github.io/Koconut/classes/KoconutNoSuchElementException.html +[koconutcomparable]: https://apexcaptain.github.io/Koconut/interfaces/KoconutComparable.html +[koconutequatable]: https://apexcaptain.github.io/Koconut/interfaces/KoconutEquatable.html +[koconutoption]: https://apexcaptain.github.io/Koconut/classes/KoconutOption.html + + + +[promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise +[maxby]: https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#maxBy +[maxbyornull]: https://apexcaptain.github.io/Koconut/classes/KoconutArray.html#maxByOrNull diff --git a/bower.json b/bower.json index 4b3ff58..b8c6e46 100644 --- a/bower.json +++ b/bower.json @@ -35,6 +35,7 @@ "src", "test", ".babelrc", + ".editorconfig", ".eslintrc.js", ".gitignore", ".prettierrc", diff --git a/desktop.ini b/desktop.ini index cb18220..3a8ecb6 100644 --- a/desktop.ini +++ b/desktop.ini @@ -1,6 +1,6 @@ -[.ShellClassInfo] -IconResource=.\res\logo.ico,0 -[ViewState] -Mode= -Vid= -FolderType=Generic +[.ShellClassInfo] +IconResource=.\res\logo.ico,0 +[ViewState] +Mode= +Vid= +FolderType=Generic diff --git a/dist/components/container/base/KoconutBoolean.d.ts b/dist/components/container/base/KoconutBoolean.d.ts index 2291fb3..7f4d9e6 100644 --- a/dist/components/container/base/KoconutBoolean.d.ts +++ b/dist/components/container/base/KoconutBoolean.d.ts @@ -1,5 +1,4 @@ import { KoconutComparable, KoconutPrimitive } from '../../../module'; -declare type targetBooleanLikeType = boolean | KoconutPrimitive; export declare class KoconutBoolean extends KoconutPrimitive implements Boolean, KoconutComparable @@ -21,7 +20,9 @@ export declare class KoconutBoolean */ constructor(boolean?: boolean | null); private static fromPrimitive; - compareTo(other: targetBooleanLikeType): KoconutPrimitive; + compareTo( + other: boolean | KoconutPrimitive, + ): KoconutPrimitive; /** * Processed all the chained object and returns original {@link KoconutBoolean} instance. * @@ -40,12 +41,11 @@ export declare class KoconutBoolean retrieve(): Promise; valueOf(): boolean; not(): KoconutBoolean; - and(other: targetBooleanLikeType): KoconutBoolean; - nand(other: targetBooleanLikeType): KoconutBoolean; - or(other: targetBooleanLikeType): KoconutBoolean; - nor(other: targetBooleanLikeType): KoconutBoolean; - xor(other: targetBooleanLikeType): KoconutBoolean; - xnor(other: targetBooleanLikeType): KoconutBoolean; - eqv(other: targetBooleanLikeType): KoconutBoolean; + and(other: boolean | KoconutPrimitive): KoconutBoolean; + nand(other: boolean | KoconutPrimitive): KoconutBoolean; + or(other: boolean | KoconutPrimitive): KoconutBoolean; + nor(other: boolean | KoconutPrimitive): KoconutBoolean; + xor(other: boolean | KoconutPrimitive): KoconutBoolean; + xnor(other: boolean | KoconutPrimitive): KoconutBoolean; + eqv(other: boolean | KoconutPrimitive): KoconutBoolean; } -export {}; diff --git a/dist/components/tool/KoconutYieldable.d.ts b/dist/components/protocol/KoconutYieldable.d.ts similarity index 100% rename from dist/components/tool/KoconutYieldable.d.ts rename to dist/components/protocol/KoconutYieldable.d.ts diff --git a/dist/components/tool/KoconutYieldable.js b/dist/components/protocol/KoconutYieldable.js similarity index 100% rename from dist/components/tool/KoconutYieldable.js rename to dist/components/protocol/KoconutYieldable.js diff --git a/dist/index.js b/dist/index.js index 3241e4b..063fc5a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -97,3 +97,5 @@ Object.defineProperty(exports, 'Pair', { var _module = require('./module'); ('use strict'); + +('use strict'); diff --git a/dist/module.d.ts b/dist/module.d.ts index b007371..f859450 100644 --- a/dist/module.d.ts +++ b/dist/module.d.ts @@ -2,7 +2,6 @@ export * from './components/KoconutOption'; export * from './components/KoconutPrimitive'; export * from './components/callback/KoconutCallbacks'; export * from './components/tool/KoconutDeprecation'; -export * from './components/tool/KoconutYieldable'; export * from './components/tool/KoconutOpener'; export * from './components/tool/KoconutTypeChecker'; export * from './components/container/base/KoconutBoolean'; @@ -13,6 +12,7 @@ export * from './components/enum/KoconutLoopSignal'; export * from './components/exception/KoconutExceptions'; export * from './components/protocol/KoconutComparable'; export * from './components/protocol/KoconutEquatable'; +export * from './components/protocol/KoconutYieldable'; export * from './components/container/KoconutIterable'; export * from './components/container/collection/KoconutCollection'; export * from './components/container/collection/array/KoconutArray'; diff --git a/dist/module.js b/dist/module.js index d409426..eb5d924 100644 --- a/dist/module.js +++ b/dist/module.js @@ -56,19 +56,6 @@ Object.keys(_KoconutDeprecation).forEach(function (key) { }); }); -var _KoconutYieldable = require('./components/tool/KoconutYieldable'); - -Object.keys(_KoconutYieldable).forEach(function (key) { - if (key === 'default' || key === '__esModule') return; - if (key in exports && exports[key] === _KoconutYieldable[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _KoconutYieldable[key]; - }, - }); -}); - var _KoconutOpener = require('./components/tool/KoconutOpener'); Object.keys(_KoconutOpener).forEach(function (key) { @@ -199,6 +186,19 @@ Object.keys(_KoconutEquatable).forEach(function (key) { }); }); +var _KoconutYieldable = require('./components/protocol/KoconutYieldable'); + +Object.keys(_KoconutYieldable).forEach(function (key) { + if (key === 'default' || key === '__esModule') return; + if (key in exports && exports[key] === _KoconutYieldable[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _KoconutYieldable[key]; + }, + }); +}); + var _KoconutIterable = require('./components/container/KoconutIterable'); Object.keys(_KoconutIterable).forEach(function (key) { @@ -289,3 +289,4 @@ Object.keys(_KoconutMap).forEach(function (key) { }, }); }); +('use strict'); diff --git a/docs/classes/Entry.html b/docs/classes/Entry.html index a8d50f6..46aa35a 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

    • Entry

    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 9be4295..71e12a6 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>
    - +

    Known Caveats

      @@ -33,12 +63,17 @@

      Repository

      +
      +
      +
      +
      +

      Release v1.0.15

      -1 Oct 2020 +1 Oct 2020
      @@ -67,18 +102,20 @@

      Major Features and Improvements

    - +

    Known Caveats

    • Following methods are deprecated.

      - `toArray` -- Commonly // `asArray` instead.
      - `toSet` -- Commonly // `asSet` instead.
      - `forEachIndexed` -- in `KoconutMap`
      - `onEachIndexed` -- in `KoconutMap`
      +
    • +



    -
    - +
    +

    Release v1.0.14

    @@ -104,11 +141,13 @@

    Bug Fixes and Other Changes

    • Mapping and filtering methods of collections with specified target destination is now propery applied to Set when the value is instance of your custom class that inherits KoconutEquatable. -Applied Methods - flatMapTo - mapTo - mapNotNullTo - flatMapIndexedTo - mapIndexedTo - mapIndexedNotNullTo - filterTo - filterNotTo - filterIndexedTo - filterNotNullTo
      +Applied Methods - flatMapTo - mapTo - mapNotNullTo - flatMapIndexedTo - mapIndexedTo - mapIndexedNotNullTo - filterTo - filterNotTo - filterIndexedTo - filterNotNullTo
    • +
    +


    -
    - +
    +

    Release v1.0.13

    @@ -125,7 +164,7 @@

    Currently Working on...

  • I'm planning to design 2 new data container classes for sequential and parallel promise chain. Those are quite similar to Sequence or Stream in Java and Kotlin.
  • -
    +

    Known Caveats

      @@ -137,11 +176,13 @@

      Known Caveats

      Repository

        -
      • API documentation of KoconutMap is completed.
        +
      • API documentation of KoconutMap is completed.
      • +
      +


      -
      -
    +
    +

    Release v1.0.12

    @@ -155,11 +196,13 @@

    Release v1.0.12

    Bug Fixes and Other Changes

      -
    • Babel@runtime is now moved to common dependencies section. I'm sorry I didn't catch that.
      +
    • Babel@runtime is now moved to common dependencies section. I'm sorry I didn't catch that.
    • +
    +


    -
    - +
    +

    Release v1.0.11

    @@ -184,11 +227,13 @@

    Bug Fixes and Other Changes

    Repository

      -
    • README for NPM is now separated. Not very different from the original README.md. Since the column on NPM README is quite narrow and table of contents navigation does not work properly. I think it's because anchor links are generated differently on GitHub and NPM. I'll only leave brief introductions and examples in the NPM README.
      +
    • README for NPM is now separated. Not very different from the original README.md. Since the column on NPM README is quite narrow and table of contents navigation does not work properly. I think it's because anchor links are generated differently on GitHub and NPM. I'll only leave brief introductions and examples in the NPM README.
    • +
    +


    -
    - +
    +

    Release v1.0.10

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

    Major Features and Improvements

  • Iterative functions, such as forEach, forEachIndexed, onEach and onEachIndexed now can be interrupted with KoconutLoopSignal.BREAK. Of course it is still available by simple boolean. To stop the iteration in the mean time, you can simply return false or return KoconutLoopSignal.BREAK. You can check example if you want to.
  • - +

    Known Caveats