bower install [email protected]:ApexCaptain/Koconut.git
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Your page title</title>
<script src="bower_components/koconut/webpack/koconut.js"></script>
</head>
<body>
...
</body>
<script>
KoconutArray.of(1, 2, 3, 4, 5)
.onEach(alert)
.process()
.then(() => alert('Nailed it!'));
</script>
</html>
mapVaues to mapValues of KoconutMap.substract to subtract of KoconutCollection.runningFoldindexed to runningFoldIndexed of KoconutCollection.New base container class KoconutBoolean is added. It is a child class that extends KoconutPrimitive<boolean> and also implements Boolean of typescript. All the methods of other classes that return KoconutPrimitive<boolean> are replcaed with it. Documentization is still being processed. Supported methods are as following.
compareTonotandnandornorxorxnoreqvNew 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.
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<boolean> or KoconutBoolean.
Following methods are deprecated.
- `toArray` -- Commonly // `asArray` instead.
- `toSet` -- Commonly // `asSet` instead.
- `forEachIndexed` -- in `KoconutMap`
- `onEachIndexed` -- in `KoconutMap`
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.
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' }
Set when the value is instance of
your custom class that inherits KoconutEquatable.
Applied Methods - flatMapTo - mapTo - mapNotNullTo - flatMapIndexedTo - mapIndexedTo - mapIndexedNotNullTo - filterTo - filterNotTo - filterIndexedTo - filterNotNullToSequence or Stream in Java and Kotlin.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.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.KoconutMap is completed.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.
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.
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.Generated using TypeDoc