This is the v13 stable release. It supersedes radashi@13.0.0, which was published briefly and removed.
Breaking Changes
Removed default size from cluster function
- The
sizeparameter is now required.
Reworked debounce function
-
Continue debouncing (in future calls) after
cancelis called. Previously,cancelwould disable debouncing, so future calls would be immediate.const func = debounce({ delay: 1000 }, mockFunc) func() func.cancel() vi.advanceTimersByTime(1001) expect(mockFunc).toHaveBeenCalledTimes(0) func() vi.advanceTimersByTime(1001) expect(mockFunc).toHaveBeenCalledTimes(1)
-
Do not have
flushcall the underlying function if no call is pending.const func = debounce({ delay: 1000 }, mockFunc) func.flush() expect(mockFunc).toHaveBeenCalledTimes(0) // Would previously have called the function
-
Expose a reference to the underlying function with the new
calleeproperty.const func = debounce({ delay: 1000 }, mockFunc) expect(func.callee).toBe(mockFunc)
Change isNumber to return true for NaN values
Returning true for NaN values allows isNumber to perform “type narrowing” in TypeScript without risking a runtime error. This is because NaN is not a valid type in TypeScript, so it cannot be separated from other numbers.
const value: number | string = NaN
if (!isNumber(value)) {
// Would previously have caused a runtime error, because `isNumber` returned false for `NaN`
value.toUpperCase()
}
isNumber(NaN) // => trueAlign the AggregateError polyfill with the native constructor
Drop support for Node 16
- The
enginesfield now requires Node 18 or higher. - The published package is transpiled to ES2022 syntax (was ES2017).
Allow lossless crush ⇄ construct use
crushnow preserves empty objects and arrays as leaf values instead of dropping them.setno longer ignoresundefinedvalues, soconstructcan restoreundefinedproperties.
Removed tolerance for null and undefined inputs
- Functions that don't accept
null/undefinedin their type signatures no longer defensively handle them at runtime and may throw instead of returning a default value. clonenow only accepts plain objects and arrays — primitives, functions, and built-ins likeMap,Set, andDateare no longer valid inputs.
trim requires both arguments
trim(str, charsToTrim)no longer defaultscharsToTrimto' '.
sort takes a direction string
- The third parameter is now
direction: 'asc' | 'desc'instead ofdesc: boolean. For example,sort(list, g, true)becomessort(list, g, 'desc').
counting and objectify return Partial<Record<…>>
- Their return types were wrapped with
Partial, since keys that never occur are absent from the result.
memo options and types reworked
MemoOptionsis now generic over the function type rather than its args tuple.- Added
cacheoption and exportedMemoized/MemoCachetypes.