@joookiwi/collection v1.12.0
Collection (javascript version)
Table of content
The way to think about this is to have the functionalities of other languages
(like Java, PHP, C#, Kotlin and even Javascript)
all in one standalone structure.
But, with a possible functional approach using the collections.
The structure is and will be in continuous change to implement almost everything that the other languages have (if it is possible).
Installation
npm install @joookiwi/collection
npm i @joookiwi/collection
npm install --save @joookiwi/collection
npm i -S @joookiwi/collection
npm install --save-dev @joookiwi/collection
npm i -D @joookiwi/collectionUsage
There are 3 different kinds of collections (which are all non-mutable).
- a minimalist (
GenericMinimalistCollectionHolder), - a lazy (
LazyGenericCollectionHolder) - and an eager (
GenericCollectionHolder) one.
So, no computation can be done "normally" in these instances.
But they can always be converted to
the Array, Set,
WeakSet (it the type is a WeakKey)
or even Map depending on the usage.
It can be separated in different categories.
1. The size methods
2. The research methods
3. The index methods
4. The validation methods
5. The transformation methods
6. The loop methods
7. The reordering methods
8. The conversion methods
9. Some utility methods (not part of the CollectionHolder)
The size methods
Those methods are associated with a size or directly compared
size|length|countisEmptyisNotEmpty
The research methods
Those methods are meant to find an element comparing it or giving a value from the collection
- get value
get|at|elementAtgetFirst|first|firstIndexedgetLast|last|lastIndexed
- get value or else
getOrElse|atOrElse|elementAtOrElse
- get value or null
getOrNull|atOrNull|elementAtOrNullgetFirstOrNull|firstOrNull|firstIndexedOrNullgetLastOrNull|lastOrNull|lastIndexedOrNull
- find first value
findFirst|find|firstfindFirstOrNull|findOrNull|firstOrNullfindFirstIndexed|findIndexed|firstIndexedfindFirstIndexedOrNull|findIndexedOrNull|firstIndexedOrNull
- find last value
findLast|lastfindLastOrNull|lastOrNullfindLastIndexed|lastIndexedfindLastIndexedOrNull|lastIndexedOrNull
The index methods
Those methods are giving or finding index values in the collection
- get index
firstIndexOf|indexOffirstIndexOfOrNull|indexOfOrNulllastIndexOflastIndexOfOrNull
- find first index
indexOfFirst|findFirstIndex|findIndexindexOfFirstOrNull|findFirstIndexOrNull|findIndexOrNullindexOfFirstIndexed|findFirstIndexIndexed|findIndexIndexedindexOfFirstIndexedOrNull|findFirstIndexIndexedOrNull|findIndexIndexedOrNull
- find last index
indexOfLast|findLastIndexindexOfLastOrNull|findLastIndexOrNullindexOfLastIndexed|findLastIndexIndexedindexOfLastIndexedOrNull|findLastIndexIndexedOrNull
The validation methods
Those methods are to give a validation on some type, value or comparison across the collection -
all|everyany|somenone- has …
hasNull|includesNull|containsNullhasDuplicate|includesDuplicate|containsDuplicatehas|includes|containshasOne|includesOne|containsOnehasAll|includesAll|containsAll
requireNotNull
The transformation methods
Those methods have the purpose to give a new collection with a possibly different type from the original collection
- filter …
filterfilterIndexedfilterNotfilterIndexedNotfilterNotNull
- slice …
slice
- take …
take|limittakeWhile|limitWhiletakeWhileIndexed|limitWhileIndexedtakeLast|limitLasttakeLastWhile|limitLastWhiletakeLastWhileIndexed|limitLastWhileIndexed
- drop …
drop|skipdropWhile|skipWhiledropWhileIndexed|skipWhileIndexeddropLast|skipLastdropLastWhile|skipLastWhiledropLastWhileIndexed|skipLastWhileIndexed
- map …
mapmapIndexedmapNotNullmapNotNullIndexed
The loop methods
Those methods are just doing a basic loop on the collection
forEachforEachIndexedonEachonEachIndexed
The reordering methods
Those methods are just changing the order to the elements of the collection
toReverse|toReversed|reversed
The conversion methods
Those methods have the sole purpose to convert the structure from a collection to another structure. It can also convert the value to a string.
toIteratortoArraytoMutableArraytoSettoMutableSettoWeakSet(only if the it is anobject|symbolor inGenericObjectCollectionHolder)toMutableWeakSet(only if it is anobject|symbolor inGenericObjectCollectionHolder)toMaptoMutableMaptoStringtoLocaleStringtoLowerCaseStringtoLocaleLowerCaseStringtoUpperCaseStringtoLocaleUpperCaseStringjoinToString|join
The utility methods
Those methods are not part of the CollectionHolder,
but are a complement to the overall robustest of the collection
- as … string
asString(This will be eventually moved in another project)asLocaleString(This will be eventually moved in another project)asLowerCaseString(This will be eventually moved in another project)asLocaleLowerCaseString(This will be eventually moved in another project)asUpperCaseString(This will be eventually moved in another project)asLocaleUpperCaseString(This will be eventually moved in another project)
- is framework collection
isCollectionHolderisCollectionHolderByStructureisMinimalistCollectionHolderisMinimalistCollectionHoldeByStructureisCollectionIteratorisCollectionIteratorByStructure
- is JavaScript collection
isArrayisArrayByStructureisTypedArrayisTypedArrayByStructureisInt8ArrayisInt8ArrayByStructureisUint8ArrayisUint8ArrayByStructureisUint8ClampedArrayisUint8ClampedArrayByStructureisInt16ArrayisInt16ArrayByStructureisUint16ArrayisUint16ArrayByStructureisInt32ArrayisInt32ArrayByStructureisUint32ArrayisUint32ArrayByStructureisBigInt64ArrayisBigInt64ArrayByStructureisBigUint64ArrayisBigUint64ArrayByStructureisFloat32ArrayisFloat32ArrayByStructureisFloat64ArrayisFloat64ArrayByStructureisSetisSetByStructureisIterator
Non-present methods
Almost every method is present in the src/method at the exception to
get(index) and get size() that is handled differently based on the type of instance.
The alias methods are not part of the extension function.
are get length() and get count().
Eventually, those methods should be present.
Contribution
You can contribute to great simple packages. All with similar behaviour across different languages (like Java, Kotlin, C# and PHP). It can be done 2 different ways:
11 months ago
11 months ago
10 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago