All items marked as "changed", "removed", or "renamed" are likely to be breaking changes. Before 1.0.0, these changes will not be announced and will only be documented in this file, so please make sure to read it thoroughly if you wish to upgrade.
0.7.0 - Unreleased
- Added:
Stack
- Added:
Queue
- Added:
PotentIterator
- Added:
ReversePotentIterator
- Added:
TupleType<T>
0.6.2 - 2024-02-08
- Fixed: builds breaking in certain build systems due to unenforced import file extensions
0.6.1 - 2024-02-08
- Changed:
potence
is no longer a CommonJS package, and all files are now ES modules - Renamed:
BaseType
->TypeofResult
- Renamed:
BaseToType<T>
->Typeof<T>
- Changed:
Objects.structure()
now uses a matchers-based API - Changed:
Structure
can now be found under'potence/objects/structure'
;
- Added:
Version.toJSON()
- Added: A number of new functions and types. Be aware that these are untested and unfinalized, and so may be subject to change or even removal in a future version. This applies to any type or function that does not appear in the official documentation.
0.6.0 - 2022-03-10
- Removed:
Strings.stripAfter()
- Removed:
Strings.stripBefore()
- Added:
Strings.skip()
- Added:
Strings.skipLast()
- Added:
Strings.skipUntil()
- Added:
Strings.skipUntilAfter()
- Added:
Strings.skipUntilLast()
- Added:
Strings.skipUntilAfterLast()
- Added:
Strings.take()
- Added:
Strings.takeLast()
- Added:
Strings.takeUntil()
- Added:
Strings.takeUntilAfter()
- Added:
Strings.takeUntilLast()
- Added:
Strings.takeUntilAfterLast()
- Added: new class
Version
to facilitate working with semantic versioning, especially semantic version parsing and comparison
- Added: new overload
mapGroup
toArrays.groupBy()
- Added: new function
Arrays.insert()
- Added: new function
Arrays.replaceAll()
- Moved: type guards (
isPrimitive
,isIterable
,isEquatable
) to theObjects
module to minimize circular dependencies
- Added: Experimental module. API not finalized and may be subject to drastic changes in future versions. Not accessible through the main module entry and not contained within the current library docs. Use at your own risk.
- Changed: The npm package now contains compiled CommonJS files (previously compiled ES modules). Due to continued poor ESM support, this should make it easier to include in existing projects alongside other libraries.
- Fixed: various circular dependencies
0.5.3 - 2021-07-08
- Fixed: issue where
Arrays.sort()
would not properly order multiple sort functions (the first would be pushed to the back)
0.5.2 - 2021-07-08
- Fixed: issue where calling
List.prototype.sort()
with a custom sort function would not sort the list properly
0.5.1 - 2021-07-08
- Fixed: issue where calling
List.prototype.sort()
would result in infinite recursion
- Fixed: circular dependencies between modules
0.5.0 - 2021-06-24
- Added: new class
List<T>
that encapsulates all relevant functions in theArrays
module - Added: new function
Arrays.count()
- Added: new function
Arrays.hasElementAt()
- Added: new function
Arrays.correlate()
- Added: new function
Arrays.range()
- Added: new function
Arrays.findIndices()
- Added: new function
Arrays.hasMultiple()
- Added: new function
Arrays.difference()
- Added: new function
Arrays.intersection()
- Added: new function
Arrays.union()
- Renamed:
Arrays.inBounds()
toArrays.isInBounds()
- Renamed:
Arrays.empty()
toArrays.isEmpty()
- Renamed:
Arrays.notEmpty()
toArrays.isNotEmpty()
- Changed: changed most generics to refer to the array itself, not the elements within, to allow the functions to return the same type that was passed in (in the case of subtyped arrays)
- Changed: use of
Arrays.isInBounds()
is now discouraged in favour ofArrays.hasElementAt()
- Changed:
Arrays.first()
,Arrays.last()
,Arrays.isEmpty()
,Arrays.isNotEmpty()
,Arrays.distinct()
, andArrays.hasDuplicates()
now accept a genericIterable<T>
instead of just arrays
- Added: new function
Assert.equals()
- Added: new function
Assert.notEquals()
- Added: new function
Assert.type()
- Added: new function
Assert.instanceOf()
- Added: new function
Assert.empty()
- Added: new function
Assert.notEmpty()
- Changed: allow
Assert.every()
to return aboolean
inside callback function
- Added: new module
- Added: new function
Numbers.roman()
- Added: new function
Numbers.closest()
- Added: new function
Numbers.exponent()
- Added: new function
Numbers.from()
- Renamed:
Numbers.even()
toNumbers.isEven()
- Renamed:
Numbers.odd()
toNumbers.isOdd()
- Renamed:
Range.between()
toRange.isBetween()
- Renamed:
Range.intersect()
toRange.intersectionPoint()
- Changed:
Range.intersectionPoint
now returnsNumber.NaN
if no intersection was found - Added: new function
Range.intersect()
- Added: new function
Range.union()
- Added: new function
Range.getOffset()
- Added: new function
Range.isEmpty()
- Added: new function
Objects.map()
- Added: new function
Objects.filter()
- Added: new function
Objects.omit()
- Added: new function
Objects.pick()
- Added: new function
Objects.is()
- Added: new function
Objects.getPropertyDescriptor()
- Added: new function
Objects.isWritable()
- Added: new function
Objects.getConstructor()
- Added: new function
Objects.clone()
- Added: new function
Strings.isEmpty()
- Added: new function
Strings.isWhitespace()
- Added: new function
Strings.forEach()
- Added: new function
Strings.chars()
- Added: new function
Strings.codePoints()
- Added: new function
Strings.splitAt()
- Added: new function
Strings.stripStart()
- Added: new function
Strings.stripEnd()
- Added: new function
Strings.stripBefore()
- Added: new function
Strings.stripAfter()
- Added: new function
Strings.pascalCase()
- Changed:
Strings.strip()
no longer strips all spaces by default (now just returns original string)
- Added: new type
Callback<T, U>
- Added: new type
Predicate<T>
- Added: new type
HexChar
- Added: new type
ExcludeProps
- Changed: updated online documentation across the board
- Changed: updated JsDocs across the board
0.4.0 - 2020-11-13
- Removed:
Assert.some()
as its usefulness was limited (you could just doAssert.that(array.some(predicate))
instead) - Changed: all assertion functions (except
Assert.every()
) now returnvoid
and are TypeScript assertion functions - Changed: all assertion functions except
Assert.that()
now no longer accept a second argument to change the failure message; instead this argument now specifies the name of the variable or property of the value that is being checked - Changed:
Assert.every()
no longer accepts a predicate as its second argument; instead it is now a callback function returning void that should throw an assertion error if the element does not pass the assertion - Added: new configuration property
stringifyOptions
(seeObjects.stringify()
)
- Added: new function
Arrays.distinct()
- Added: new function
Arrays.hasDuplicates()
- Fixed:
Arrays.removeAt()
previously didn't check if the index was in-bounds; now it throws an error if the index is out of bounds - Fixed:
Arrays.replace()
using wrong function name in its error text - Fixed:
Arrays.zip()
andArrays.groupBy()
not allowing readonly arrays to be passed - Fixed: improved
Arrays.clearNull()
performance
- Removed: all function aliases, including
Arrays.approaches()
,Arrays.closeTo()
,Arrays.average()
, andArrays.avg()
(see edff19f2 for the reasoning behind this change) - Removed:
Numbers.center()
in favor ofRange.center()
- Removed:
Numbers.integral()
in favor ofNumber.isInteger()
- Renamed:
Numbers.float()
toNumbers.isFloat()
to better communicate its intent - Renamed:
Numbers.safeFloat()
toNumbers.isSafeFloat()
to better communicate its intent - Renamed:
Numbers.unsafeFloat()
toNumbers.isUnsafeFloat()
to better communicate its intent - Fixed:
Numbers.isFloat()
did not handleNaN
,Infinity
and-Infinity
correctly
- Renamed:
Objects.equals()
toObjects.equal()
as it sounds better grammatically - Changed: hid some previously exposed internal types like
MappedStructure<T>
- Changed:
Objects.structure()
is now by default a non-exhaustive check (meaning the object may have more properties than the structure declares) - Changed:
Objects.equal()
now performs a simple equality check if object does not implementEquatable
(previously performed a shallow comparison) - Changed:
Objects.hasProperty()
andObjects.hasFunction()
are now type guards - Changed:
Objects.hasProperty()
andObjects.hasFunction()
can now be called on primitive types too (previously always returnedfalse
) - Added: new function
Objects.stringify()
- Added: second parameter to
Objects.structure()
that may be passed to make the check exhaustive
- Added: new function
Strings.capitalize()
- Added: new function
Strings.uncapitalize()
- Added: new type alias
Truthy<T>
- Added: new type alias
Falsy<T>
- Added: new interface
Iterable
and corresponding type guardisIterable()
- Fixed:
Instantiable
: leaving the second type parameter as its default now allows you specify any number of constructor arguments of any type (previously allowed no arguments)
- Added: online documentation for all modules, functions, and types
- Changed: updated JsDocs across the board
- Fixed:
Range
is now properly re-exported from the main module entry - Changed: Added
ReadonlyRange
as export from main module entry
0.3.0 - 2020-11-05
- Changed: the assertion functions
truthy()
,falsy()
,notNull()
,every()
, andsome()
now return the value that was passed in to allow for more fluent usage syntax
- Added: new function
Range.wrap(value)
- Changed: the
Objects
functionsstructure()
,swap()
, andequatable()
now only expect anobject
as their first argument (previously expected an object with an index signature) - Changed:
Objects.structure()
now accepts any object (previously threw an error if the object was not an object literal) - Changed:
Objects.equatable()
now throws an error if target object contains a non-function "equals" property
- Changed: the helper type
ObjectLiteral<T>
now stands forRecord<string | number | symbol, T>
(fromRecord<string, T>
)
- Changed: updated several JsDoc texts to be more descriptive
0.2.0 - 2020-09-13
- Added: new function
Arrays.removeAt(array, index)
- Added: new overload
Arrays.sort(array, ...sortFunctions)
- Added: new function
Arrays.moveAll(array, by)
- Added: new function
Arrays.zip(array, ...otherArrays)
- Added: new function
Arrays.groupBy(array, (item) => property)
- Added: new function
Objects.swap(object, from, to)
- Added: new function
Objects.equals(object, ...otherObjects)
- Added: new function
Objects.equatable(object)
- Added: new function
Objects.hasProperty(object, propertyName, propertyType)
- Added: new function
Objects.hasFunction(object, functionName, argumentCount)
- Added: new function
Strings.camelCase(string)
- Added: new function
Strings.prefix(string, prefix)
- Added: new function
Strings.suffix(string, suffix)
- Added: new function
Strings.isUrl(string)
- Added: new type
ArrayType<T>
- Added: new type
Equatable
- Added: new function
isPrimitive(target)
- Added: new function
isEquatable(target)
0.1.1 - 2020-09-13
- Fixed: "directory import '..." is not supported resolving ES modules" error when attempting to import from main module entry in node.js projects
0.1.0 - 2020-09-13
- Changed: mark package as being of type "module" to enable ESM in node.js projects
- Fixed: build errors by publishing project from build directory
- Removed: redundant .npmignore
- Fixed: build errors
- Fixed: missing .npmignore resulting in incorrect npm packaging
- Initial release