1
0
Fork 0
js-utils/docs/api/js-utils.md

3.9 KiB

Home > @apextoaster/js-utils

js-utils package

Classes

Class Description
ArrayMapper
AsyncTracker Async resource tracker using node's internal hooks.This probably won't work in a browser. It does not hold references to the resource, to avoid leaks. Adapted from https://gist.github.com/boneskull/7fe75b63d613fa940db7ec990a5f5843#file-async-dump-js
ChildProcessError
InvalidArgumentError
MissingKeyError
NotFoundError
NotImplementedError
TimeoutError

Functions

Function Description
concat(chunks)
countOf(val) Calculate the "length" of an array or value.Arrays return their length, single values return 1, and nil values return 0. This counts the number of elements that setOrPush would add.
defaultWhen(condition, items)
defer(ms, val) Resolve after a set amount of time.
doesExist(val) Check if a variable is not nil.
encode(chunks, encoding)
entriesOf(map)
filterNil(list) Remove any null or undefined items from the list.
getTestLogger(verbose)
isDebug()
isNil(val)
makeDict(map) Turns a map or dict into a dict
makeMap(val) Clone a map or map-like object into a new map.
mergeList(parts) Merge arguments, which may or may not be arrays, into one return that is definitely an array.
mergeMap(target, source)
mustCoalesce(values) Return the first value that is not nil.
mustExist(val) Assert that a variable is not nil and return the value.
mustFind(list, predicate) Find a value matching the given predicate or throw.
mustGet(map, key) Get an element from a Map and guard against nil values.
pushMergeMap(args)
removePid(path)
setOrPush(map, key, val) Set a map key to a new array or push to the existing value.
signal(signals)
spyLogger(spies)
timeout(ms, oper) Reject after a set amount of time if the original promise has not yet resolved.
waitForChild(child)
writePid(path)

Interfaces

Interface Description
Dict
ExternalModule

Variables

Variable Description
SIGNAL_RELOAD
SIGNAL_RESET
SIGNAL_STOP

Type Aliases

Type Alias Description
MapLike A Map or dictionary object with string keys and TVal values.
ModuleCtor
Nil Unset value.
Optional Value that may be nil.