corextensions 1.1.1 corextensions: ^1.1.1 copied to clipboard
Many helpful extensions to the core classes like string and iterable.
The corextensions package is made up of many extensions on core classes such as
Getting Started #
To import this package, include the following code:
Example Properties #
For example, the following lists a few of these extensions:
trueif an iterable has length 1.
Iterable.smallestWherereturns the smallest value in this iterable following a mapping to
trueif the length of this iterable is the same as the other iterable provided.
Iterable.countreturns the number of times a value is present in the iterable.
List.mapWithIndexreturns an iterable which has been mapped using this list, where we are provided with both the value at the index, and the index itself.
trueif the list has an element present more than once, checked by the equality
List.swapswaps two elements within the list.
List.allIndicesOfreturns all the indices of a value in the list.
trueif this set has the same values as the other set, in any order.
Iterable.sumWherereturns the sum of elements in the iterable following a function returning a number.
String.capitalisereturns the string with the first letter replaced with the original one in upper case.
String.removeExtraSpacereturns the string with whitespace removed from not just the start and the end, but also the middle, with the assumption that there should only be 1 space between 2 words.
String.splitByAllsplits the string by all the delimiters provided.
String.replaceLastreplaces the last occurence of a substring from the string.
Map.firstValueWherereturns the first value that satisfies the provided function.
Map.reverseflips keys and values.
On top of these, there is also the function
zipTwoLists which zips two lists in the provided order.
Examples using these properties can be found in the example section.
Documentation on the package can be found here.
Features and bugs #
To suggest additional properties or report bugs, report it here.