A set of utilities shared between my projects
Function documentation available here
- Fix: Update return types of
isArray
andisObject
to use an extensive conditional type to replace what used to work in TS 4.7
Undo changes to isObject
from 4.0.6
. TS narrowing in 4.8.2 is broken.
- Fix: correctly narrow return type of
isObject
- Fix: correctly narrow return type of isArray for
{}
arguments
- Fix: narrowed type for
isArray
is inferred correctly forreadonly
arrays
- Update
isArray
to be compatible with TS 4.8 changes
SortedQueue
: Fixed an issue where inserting an item before the first one would cause the queue to lose track of items
- Node.js 12+ is now required
- Fix compatibility of
wait()
with Electron ifunref
istrue
- Dependency updates
- Fixed compatibility with TypeScript 4.2
- The argument to
resolve
ofDeferredPromise
is no longer optional, except forPromise<void>
- The typeguard
isObject
no longer narrows the type of the argument toobject
- Renamed the following types:
DropLast
->Lead
TakeLast
->Last
TakeLastArgument
->LastArgument
- TypeScript 4.1 is now required
- Added the following types:
FixedIndizesOf<T[]>
- LikeIndizesOf
, but does not include the typenumber
if the tuple/array is variable-lengthTail<T[]>
- Returns all but the first item's type in a tuple/arrayPush<List[], Item>
- Returns the given tuple/array with the item type appended to itConcat<T1[], T2[]>
- Concatenates the given tuples/arraysTupleOf<T, N>
- Returns a tuple of lengthN
with item typesT
.Range<N>
- Creates a Union of all numbers (converted to string) from 0 to N (exclusive), e.g.Range<4>
is equal to"0" | "1" | "2" | "3"
.RangeFrom<N, M>
- Creates a Union of all numbers from N (inclusive) to M (exclusive), e.g.RangeFrom<2, 4>
is equal to"2" | "3"
.IsGreaterThan<N, M>
- is equal totrue
ifN > M
, otherwisefalse
IsLessThanOrEqual<N, M>
- is equal totrue
ifN <= M
, otherwisefalse
IsLessThan<N, M>
- is equal totrue
ifN < M
, otherwisefalse
IsGreaterThanOrEqual<N, M>
- is equal totrue
ifN >= M
, otherwisefalse
- The type
CallbackAPIReturnType
now works withstrictNullChecks
. - The type
Promisify
is no longer experimental and no longer messes up the inferred signature argument names
- Added optional
unref
parameter toasync
->wait(ms, [unref])