This project is a collection of utilities, collected from my other Typescript projects, lightly documented and heavily tested.
Install:
yarn add -D @apextoaster/js-utilsAnd import:
import { mustExist } from '@apextoaster/js-utils';The library is bundled and has no dependencies.
Please see the complete API docs for the full function list.
Features utilities and helpers for:
- Array
- assertions/guards:
hasItemsisArrayfor bothArray/ReadonlyArrayisEmptylengthOf
- conversion
filterZiptoArray
- assertions/guards:
- Array Mapper
- array-to-map converter, reduces an array of values to a map, using an array of keys
- Async
- timed promises
defer/deferValuedeferUntiltimeout
- timed promises
- Buffer
- concatenation
concatencode
- concatenation
- Checklist
- allow/deny list
- Child Process
childResultwriteInput
- Env Vars
isDebug
- Errors
- nestable, typed error
ChildProcessErrorInvalidArgumentErrorMissingKeyErrorNotFoundErrorNotImplementedErrorTimeoutError
- nestable, typed error
- Logger
- test logging helpers
- Map
- types
MapLike
- assertions/guards:
mustGet
- null-safe helpers
getOrDefault
- helpers for
Map<K, Array<V>>getHead/getHeadOrDefaultsetOrPush
- concat/merge
mergeMappushMergeMap
- conversion
entriesOfmakeDictmakeMappairsToMap
- types
- Math
- predicates for functional methods
sum
- predicates for functional methods
- Maybe
- types
MaybeNone
- assertions/guards
doesExistmustExistmustDefaultmustFindremoveNone
- null-safe helpers
isNoneisSome
- types
- Predicate
- types for functional methods
- Reflect
getConstructorgetMethods
- Signal
- wait for OS signal
signal
- wait for OS signal
- String
leftPadtrimwith suffix