Skip to content

Latest commit

 

History

History
98 lines (83 loc) · 5.06 KB

js-utils.md

File metadata and controls

98 lines (83 loc) · 5.06 KB

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
Checklist
ChildProcessError
InvalidArgumentError
MissingKeyError
NotFoundError
NotImplementedError
TimeoutError

Enumerations

Enumeration Description
ChecklistMode

Functions

Function Description
concat(chunks)
constructorName(val)
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.
getConstructor(val)
getHead(map, key)
getHeadOrDefault(map, key, defaultValue)
getMethods(value)
getOrDefault(map, key, defaultValue)
getTestLogger(verbose)
isDebug()
isNil(val) Check if a value is nil.
leftPad(val, min, fill)
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.TODO: rename to mustDefault
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.
normalizeMap(map)
pairsToMap(pairs)
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.
trim(val, max, tail)
waitForChild(child)
writePid(path)
writeValue(stream, value)

Interfaces

Interface Description
ArrayMapperOptions
ChecklistOptions
ChildOptions
ChildResult
Dict
ExternalModule

Variables

Variable Description
SIGNAL_RELOAD
SIGNAL_RESET
SIGNAL_STOP

Type Aliases

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