npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@joookiwi/collection

v1.11.2

Published

A Javascript implementation of a collection based on Array (from Javascript/Java/Kotlin/C#/PHP), Set (from Javascript/Java/Kotlin) and List (from Java/Kotlin/C#)

Downloads

193

Readme

Collection (javascript version)

version downloads

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/collection

Usage

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|count
  • isEmpty
  • isNotEmpty

The research methods

Those methods are meant to find an element comparing it or giving a value from the collection

  • get|at|elementAt

  • getFirst|first|firstIndexed

  • getLast|last|lastIndexed

  • getOrElse|atOrElse|elementAtOrElse

  • getOrNull|atOrNull|elementAtOrNull

  • getFirstOrNull|firstOrNull|firstIndexedOrNull

  • getLastOrNull|lastOrNull|lastIndexedOrNull

  • findFirst|find|first

  • findFirstOrNull|findOrNull|firstOrNull

  • findFirstIndexed|findIndexed|firstIndexed

  • findFirstIndexedOrNull|findIndexedOrNull|firstIndexedOrNull

  • findLast|last

  • findLastOrNull|lastOrNull

  • findLastIndexed|lastIndexed

  • findLastIndexedOrNull|lastIndexedOrNull

The index methods

Those methods are giving or finding index values in the collection

  • firstIndexOF|indexOf

  • firstIndexOfOrNull|indexOfOrNull

  • lastIndexOf

  • lastIndexOfOrNull

  • indexOfFirst|findFirstIndex|findIndex

  • indexOfFirstOrNull|findFirstIndexOrNull|findIndexOrNull

  • indexOfFirstIndexed|findFirstIndexIndexed|findIndexIndexed

  • indexOfFirstIndexedOrNull|findFirstIndexIndexedOrNull|findIndexIndexedOrNull

  • indexOfLast|findLastIndex

  • indexOfLastOrNull|findLastIndexOrNull

  • indexOfLastIndexed|findLastIndexIndexed

  • indexOfLastIndexedOrNull|findLastIndexIndexedOrNull

The validation methods

Those methods are to give a validation on some type, value or comparison across the collection

  • all|every

  • any|some

  • none

  • hasNull|includesNull|containsNull

  • hasDuplicate|includesDuplicate|containsDuplicate

  • has|includes|contains

  • hasOne|includesOne|containsOne

  • hasAll|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

  • filterIndexed

  • filterNot

  • filterIndexedNot

  • filterNotNull

  • slice

  • take|limit

  • takeWhile|limitWhile

  • takeWhileIndexed|limitWhileIndexed

  • takeLast|limitLast

  • takeLastWhile|limitLastWhile

  • takeLastWhileIndexed|limitLastWhileIndexed

  • drop|skip

  • dropWhile|skipWhile

  • dropWhileIndexed|skipWhileIndexed

  • dropLast|skipLast

  • dropLastWhile|skipLastWhile

  • dropLastWhileIndexed|skipLastWhileIndexed

  • map

  • mapIndexed

  • mapNotNull

  • mapNotNullIndexed

The loop methods

Those methods are just doing a basic loop on the collection

  • forEach
  • forEachIndexed
  • onEach
  • onEachIndexed

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.

  • toIterator
  • toArray
  • toMutableArray
  • toSet
  • toMutableSet
  • toWeakSet (only if the it is an object|symbol or in GenericObjectCollectionHolder)
  • toMutableWeakSet (only if it is an object|symbol or in GenericObjectCollectionHolder)
  • toMap
  • toMutableMap
  • toString
  • toLocaleString
  • toLowerCaseString
  • toLocaleLowerCaseString
  • toUpperCaseString
  • toLocaleUpperCaseString
  • joinToString|join

The utility methods

Those methods are not part of the CollectionHolder, but are a complement to the overall robustest of the collection

  • 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)

  • isCollectionHolder

  • isCollectionHolderByStructure

  • isMinimalistCollectionHolder

  • isMinimalistCollectionHoldeByStructure

  • isCollectionIterator

  • isCollectionIteratorByStructure

  • isArray

  • isArrayByStructure

  • isTypedArray

  • isTypedArrayByStructure

  • isInt8Array

  • isInt8ArrayByStructure

  • isUint8Array

  • isUint8ArrayByStructure

  • isUint8ClampedArray

  • isUint8ClampedArrayByStructure

  • isInt16Array

  • isInt16ArrayByStructure

  • isUint16Array

  • isUint16ArrayByStructure

  • isInt32Array

  • isInt32ArrayByStructure

  • isUint32Array

  • isUint32ArrayByStructure

  • isBigInt64Array

  • isBigInt64ArrayByStructure

  • isBigUint64Array

  • isBigUint64ArrayByStructure

  • isFloat32Array

  • isFloat32ArrayByStructure

  • isFloat64Array

  • isFloat64ArrayByStructure

  • isSet

  • isSetByStructure

  • isIterator


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: