Skip to content

Releases: joooKiwi/enumeration

JS / TS v3.1.0 to v3.12.0

Choose a tag to compare

@joooKiwi joooKiwi released this 23 Jul 14:28

Those updates are centered about the "joookiwi/collection"

JS / TS 3.0.0

Choose a tag to compare

@joooKiwi joooKiwi released this 15 Aug 02:13

Big changes to the javascript implementation for the upcoming Java & Kotlin version.

In this change, the type order has been changed.
By that, the Enum has no change due to having only optional types.
But, the inheritor (like the EnumWithParent) have the changed

  • Enum(erable)With(Nullable)Parent [ORDINAL, NAME, PARENT] → [PARENT, ORDINAL?, NAME?]
  • Enum(erable)With(Nullable)GrandParent [ORDINAL, NAME, PARENT, GRAND_PARENT] → [PARENT, GRAND_PARENT, ORDINAL?, NAME?]
  • Enum(erable)With(Nullable)GreatGrandParent [ORDINAL, NAME, PARENT, GRAND_PARENT, GREAT_GRAND_PARENT] → [PARENT, GRAND_PARENT, GREAT_GRAND_PARENT, ORDINAL?, NAME?]

Most notably, the protected methods in the CompanionEnum are now more separated instead of not customizable:

  • validation
    • edge case numeric
      • new _isNotInEdgeCaseNumericByString(string, PossibleString)
      • new _isNotInEdgeCaseNumericByNumber(number, PossibleNumber)
    • inherited enumerable member
      • new _isNotInInheritedEnumerableMembers(string, PossibleString)
    • excluded name
      • new _isNotInExcludedNames(string, PossibleString)
    • is in ordinal
      • new isInOrdinalsByString(NumberTemplate, PossibleString)
      • new isInOrdinalsByNumber(number, PossibleNumber): ORDINAL
      • new isInOrdinalsByBigInt(bigint, PossibleBigInt): ORDINAL
    • is positive
      • new isPositiveByString(NumberTemplate, PossibleString)
      • new isPositiveByNumber(number, PossibleNumber)
      • new isPositiveByBigInt(bigint, PossibleBigInt)
    • is not over MAX_VALUE
      • new isNotOverMaxValueByString(NumberTemplate, PossibleString)
      • new isNotOverMaxValueByNumber(number, PossibleNumber)
      • new isNotOverMaxValueByBigInt(bigint, PossibleBigInt)
    • is not a floating value
      • new isNotAFloatingNumberByString(NumberTemplate, PossibleString)
      • new isNotAFloatingNumberByNumber(number, PossibleNumber)
    • get valid value
      • _getValueByEnumerable(Enumerable): ENUMERABLE_getValidValueByEnumerable(Enumerable): ENUMERABLE
      • new _getValueByString(NonNullable<unknown>, string, PossibleString, ENUMERABLE_CONSTRUCTOR): ENUMERABLE
    • get value from …
      • new _getValueFromReflection(string, PossibleString): ENUMERABLE
      • new _getValueFromOrdinals(ORDINAL, PossibleNumeric): ENUMERABLE
      • _getValueFromParentInValues_getValueFromValuesByParent(Enumerable): ENUMERABLE
      • _getValueFromGrandParentInValues_getValueFromValuesByGrandParent(Enumerable): ENUMERABLE
      • _getValueFromGreatGrandParentInValues_getValueFromValuesByGreatGrandParent(Enumerable): ENUMERABLE
    • get valid name
      • new _getValidName(string, PossibleString): string
    • get valid ordinal
      • new _getValidOrdinalByNumber(number, PossibleNumber): ORDINAL
      • new _getValidOrdinalByBigInt(bigint, PossibleBigInt): ORDINAL
  • get non null
    • new _getNonNullValueFromGetValue(T?): T
    • new _getNonNullValueFromGetName(T?): T
    • new _getNonNullValueFromGetOrdinal(T?): T
  • get value
    • _getValueByEnumerable(Enumerable): ENUMERABLE now readonly
    • _getValueByString(string, PossibleString): ENUMERABLE now readonly
    • _getValueByNumber(number, PossibleNumber): ENUMERABLE now readonly
    • _getValueByBigInt(bigint, PossibleBigInt): ENUMERABLE now readonly
  • get name
    • _getNameByEnumerable(Enumerable): NAME now readonly
    • _getNameByString(string, PossibleString): NAME now readonly
    • _getNameByNumber(number, PossibleNumber): NAME now readonly
    • _getNameByBigInt(bigint, PossibleBigInt): NAME now readonly
  • get ordinal
    • _getOrdinalByEnumerable(Enumerable): ORDINAL now readonly
    • _getOrdinalByString(string, PossibleString): ORDINAL now readonly
    • _getOrdinalByNumber(number, PossibleNumber): ORDINAL now readonly
    • _getOrdinalByBigInt(bigint, PossibleBigInt): ORDINAL now readonly

The Array are changed to a CollectionHolder in the EnumConstants

  • ENUMERABLE_MEMBERS
  • ENUMERABLE_WITH_PARENT_MEMBERS
  • ENUMERABLE_WITH_GRAND_PARENT_MEMBERS
  • ENUMERABLE_WITH_GREAT_GRAND_PARENT_MEMBERS
  • COMPANION_ENUM_MEMBERS
  • COMPANION_ENUM_WITH_PARENT_MEMBERS
  • COMPANION_ENUM_WITH_GRAND_PARENT_MEMBERS
  • COMPANION_ENUM_WITH_GREAT_GRAND_PARENT_MEMBERS
  • EVERY_ENUMERABLE_MEMBER
  • EVERY_COMPANION_ENUM_MEMBER

There is also a new exception ForbiddenNameException in order to capture some forbidden names (by the inheritors) when retrieving from getValue, getName or getOrdinal.

There is new Regex (RegExp) in the EnumConstants that will be used eventually

  • EXPONENTIAL_REGEX
  • UNICODE_EXPONENTIAL_REGEX
  • HEXADECIMAL_REGEX
  • BINARY_REGEX

The max number is now changed to be the maximum Integer (32-bit number)

  • from 2¹⁰²⁴ - 1 to 2³² - 1

New types were added:

  • In the Enumerable.types
    • PossibleEnumerableMembers
    • ValueByEnumerableConstructorAndEnumerableName
    • deprecation of the ValueByEnumerableConstructorAndEnumerableOrdinal
    • EnumWithNullableParentGeneralType
    • EnumWithParentGeneralType
    • EnumWithNullableGrandParentGeneralType
    • EnumWithGrandParentGeneralType
    • EnumWithNullableGreatGrandParentGeneralType
    • EnumWithGreatGrandParentGeneralType
    • EnumerableWithNullableParentGeneralType
    • EnumerableWithParentGeneralType
    • EnumerableWithNullableGrandParentGeneralType
    • EnumerableWithGrandParentGeneralType
    • EnumerableWithNullableGreatGrandParentGeneralType
    • EnumerableWithGreatGrandParentGeneralType
  • In the companion/types
    • ImpossibleNames
    • PossibleCompanionEnumMembers
    • CompanionEnumType
    • CompanionEnumDeclarationType
    • CompanionEnumWithParentType
    • CompanionEnumWithParentDeclarationType
    • CompanionEnumWithGrandParentType
    • CompanionEnumWithGrandParentDeclarationType
    • CompanionEnumWithGreatGrandParentType
    • CompanionEnumWithGreatGrandParentDeclarationType
  • In the Singleton.types
    • CompanionEnumDeclarationSingleton
    • CompanionEnumWithParentDeclarationSingleton
    • CompanionEnumWithGrandParentDeclarationSingleton
    • CompanionEnumWithGreatGrandParentDeclarationSingleton

JS / TS: 2.7.0

Choose a tag to compare

@joooKiwi joooKiwi released this 27 Jul 22:02

The EnumHelper is now removed from the project
The Enum now has the default values (apparently I did forgot to added it)

And a simple update of the collection dependency (1.1.0 to 1.2.0)

JS / TS 2.4.0

Choose a tag to compare

@joooKiwi joooKiwi released this 03 Jul 04:51

Changes in the enumerable folder

There is a new way to implement the default value.
Originally, it could have been done by only _DEFAULT,
but some exception could be thrown if something other was provided.

So now, there is only the NullEnumerableException and UnhandledValueException that can be thrown by the get default method even if an unexpected exception is thrown by the values.

Also, there is 3 different implementation depending on your needs.
By using _DEFAULT, only an Enumerable is supported.
As for the _DEFAULT_NAME, it can be a string (primitive or object)
And for the _DEFAULT_ORDINAL, it can be a number or bigint (primitive or object)


*Eventually, there will be methods to confirm if the value exist instead of just throwing exception (like in C#)*

Changes in the collection folder

The collection folder has been relocated to a different repository.

The package (collection) can be used independently.
If you want to see how it handle the changes. See its release note.


(Quick note, the Java & Kotlin are in their way)

JS/TS: 2.3.0

Choose a tag to compare

@joooKiwi joooKiwi released this 19 Jun 00:55

Changes in the enumerable folder

The unused types were removed.
Meaning that EnumerableConstructorFromEnumerableConstructorOrCompanionEnum, CompanionEnumIfNameOfEnumerable, CompanionEnumIfOrdinalOfEnumerable, CompanionEnumIfOrdinalOrNameOfEnumerable, Enumerable[Name|Ordinal?]ByEnumerableConstructor, Enumerable[Name|Ordinal?]ByEnumerableConstructorAndEnumerable, Enumerable[Name|Ordinal?]ByEnumerableConstructorAndName & Enumerable[Name|Ordinal?]ByEnumerableConstructorAndOrdinal are no longer present.

Changes in the CollectionHolder

The function were added to give more opportunity to use other languages features

  • (new) any
  • (new) all
  • (new) none
  • (new) get with 2 counterpart getOrElse and getOrNull
  • (new) indexOf and lastIndexOf
  • filterByIndexfilterIndexed
  • filterNotByIndexfilterIndexedNot
  • filterNonNullfilterNoNull
  • mapIndexmapIndexed
  • forEachIndexforEachIndexed
  • (new) requireNoNulls
  • (new) toMap and toMutableMap

Changes in typing

In order to have more generic usage, some names were changed.
With this, it could be use in different methods.
It will also be more descriptive on what they have.

  • JoinCallback → ValueWithStringReturnCallback
  • MapCallback → ValueIndexWithReturnCallback
  • MapIndexCallback → ValueIndexValueWithReturnCallback
  • ForEachCallback → ValueIndexCallback
  • ForEachIndexCallback → ValueIndexValueCallback
    And there is also type removal due to some "Typescript excessive deep possibly infinite" errors
  • IsEmpty
  • IsNotEmpty
  • FilterNonNull

Also, note that the collection will eventually be in its own repository.

JS/TS: 2.2.0

Choose a tag to compare

@joooKiwi joooKiwi released this 12 Jun 17:02

Addition of new features:

  • join now has more arguments that it can receive (like the Kotlin counterpart)
  • toWeakSet and to toMutableWeakSet is now present
  • reverse is now present (with 2 arguments, start and end)
  • hasNull (with their counterpart, containsNull & includesNull) is now present
  • The collection now has the index parameter (like in Array)

Some performance optimization were used (thanks to JsPerf) on the collection methods and the companion enum initialization.

Minor changes (in the AbstractCollectionHolder)

  • Renaming of get _iterable to get _reference
  • Removal of get _set

(Keep in mind that the changes only apply to the Javascript part since there is no other so far)

JS / TS 2.5.0

Choose a tag to compare

@joooKiwi joooKiwi released this 04 Jul 20:09

In this release, there will be new classes in order to have less boilerplace code when having the "inheritance".

Also, there will be new kind of inheritance with the nullability in mind.
This was done in order to be compilable in Kotlinwith its nullability system.
By that change, there will be 2 different kind of structures depending on the nullability that you want.

(The types have been omitted in order to keep the interface as clear as possible)

interface Enumerable {
    get name(): NAME
    get ordinal(): ORDINAL
}

interface EnumerableWithNullableParent
    extends Enumerable {
    get parent(): NullOr<PARENT>
}
interface EnumerableWithParent
    extends EnumerableWithNullableParent {
    get parent(): PARENT
}

interface EnumerableWithNullableGrandParent
    extends EnumerableWithNullableParent {
    get grandParent(): NullOr<GRAND_PARENT>
}
interface EnumerableWithGrandParent
    extends EnumerableWithParent, EnumerableWithNullableGrandParent {
    get grandParent(): GRAND_PARENT
}

interface EnumerableWithNullableGreatGrandParent
    extends EnumerableWithNullableParent {
    get greatGrandParent(): NullOr<GREAT_GRAND_PARENT>
}
interface EnumerableWithGreatGrandParent
    extends EnumerableWithGrandParent, EnumerableWithNullableGreatGrandParent {
    get greatGrandParent(): GREAT_GRAND_PARENT
}

In order to have a better inheritance, a new class (in the helper folder) was added, KnownEnumConstructors.
With that, when attempting to use the getLastPrototype will be handled properly once the instance is added.

The BasicCompanionEnum was chosen to not interfere with the value. But since it doesn't cause any trouble.
The name has been renamed to CompanionEnum directly.
Meaning that:

  • BasicCompanionEnumCompanionEnum
  • BasicCompanionEnumDeclarationCompanionEnumDeclaration
  • BasicSingletonCompanionEnumSingletonCompanionEnum
  • EnumHelper.isBasicCompanionEnumEnumHelper.isCompanionEnum

Changes to the EnumHelper

By the fact that the EnumHelper was only using a namespace in Typescript, it makes its less relevant. But still useful if the utility methods can be attached in a single exportation.

By that, all of the methods has been upgraded to first-member function instead of being related to the EnumHelper namespace.
Also, it has been relocated in the folder src/helper.
You can now use

  • isEnum instead of EnumHelper.isEnum
  • isCompanionEnum instead of EnumHelper.isBasicCompanionEnum
  • isEnumByStructure instead of EnumHelper.isEnumerableByStructure
  • isCompanionEnumByStructure instead of EnumHelper.isCompanionEnumByStructure
  • getCompanion instead of EnumHelper.getCompanion
  • getLastPrototype instead of EnumHelper.getLastPrototype

And there is new utility method for the new implementations:

  • isCompanionEnumWithParent
  • isCompanionEnumWithParentByStructure
  • isCompanionEnumWithGrandParent
  • isCompanionEnumWithGrandParentByStructure
  • isCompanionEnumWithGreatGrandParent
  • isCompanionEnumWithGreatGrandParentByStructure
  • isEnumWithNullableParent
  • isEnumWithParent
  • isEnumWithParentByStructure
  • isEnumWithNullableGrandParent
  • isEnumWithGrandParent
  • isEnumWithGrandParentByStructure
  • isEnumWithNullableGreatGrandParent
  • isEnumWithGreatGrandParent
  • isEnumWithGreatGrandParentByStructure