User
-
Provides wrappers/enhancements for functions
-
Key capabilities:
- Logging, timing, retry, caching
- Control execution (debounce, throttle, lock, once)
- Transform input/output
- Error handling and safety
- Composition and chaining
A. Logging & Monitoring
log(fn)ā logs calls and resultstime(fn)ā measures execution timeprofile(fn)ā detailed table of durationchangelog(fn)ā logs changes in object outputsstats(fn)ā tracks number of calls, avg timewatch(fn)ā subscribe to outputsfeedback(fn, logger)ā logs input/output
B. Execution Control
once(fn)ā runs only onceafter(fn, n)ā runs after n callsbefore(fn, n)ā runs at most n timeslimit(fn, max)ā limits number of callslock(fn)ā prevents concurrent executiononcePerArgs(fn)ā runs once per argument comboqueue(fn)ā sequential executiondelayFn(fn, delay)ā delay executiondelayResult(fn, ms)ā delay return valuedelayEach(fn, delayMs)ā sequential with delayafterIdle(fn, timeout)ā browser idle executionsmartIdle(fn, options)ā idle execution with cancel
C. Error Handling & Safety
catch(fn, onError, fallback)ā error catchsandbox(fn, timeout)ā safe execution with error handlingsafeJson(fn)ā catches JSON parsing errorstimeLimit(fn, timeout)ā rejects after timeoutcancelable(fn)ā cancel in-flight promise
D. Input/Output Transformation
validate(fn, validator)ā validate argumentsmask(fn, masker)ā transform argumentsrestrict(fn, isAllowed)ā allow/disallow calltap(fn, tapFn)ā side effect without affecting returntransformOutput(fn, transformer)ā change outputlocale(fn, formatter)ā format input/outputunit(fn, unit)ā wraps output with value/unit/timestamp
E. Caching & Memoization
memo(fn)ā caches resultsreplay(fn)ā returns cached result for identical args
F. Functional Composition
pipe(...fns)ā left-to-right compositionchainable(fn)ā chain calls, collect results
G. Retry & Simulation
retry(fn, retries, delayMs)ā retry failing fnsimulate(fn, options)ā simulate failure/delay/corruptionrandomBehavior(fn, behaviors)ā random behaviorrandomizeArgs(fn)ā shuffle arguments
H. Undo & History
undoable(fn, inverseFn)ā supports undohistory(fn)ā tracks args/results
I. Conditional Execution
ensure(fn, validator)ā ensures output passesfilterArgs(fn, filterFn)ā executes only if condition passesdelayIf(fn, condition, delayMs)ā delays conditionallyalertOn(fn, condition)ā logs alerts if condition truewarnOnArgs(fn, warningFn)ā warns on suspicious inputpredict(fn, modelFn)ā adds prediction based on outputeventual(fn, checkFn, interval)ā polls until condition true
J. Repeat & Batch
repeat(fn, n)ā repeat function n timesbatch(fn, chunkSize, cb)ā executes in chunks
K. Miscellaneous
hook(fn, {before, after})ā pre/post hooksevolve(fn, evolver)ā mutate or extend output
FunctionWrapper
ā
āā Logging & Monitoring
ā āā log()
ā āā time()
ā āā profile()
ā āā changelog()
ā āā stats()
ā āā watch()
ā āā feedback()
ā
āā Execution Control
ā āā once()
ā āā after()
ā āā before()
ā āā limit()
ā āā lock()
ā āā oncePerArgs()
ā āā queue()
ā āā delayFn()
ā āā delayResult()
ā āā delayEach()
ā āā afterIdle()
ā āā smartIdle()
ā
āā Error Handling & Safety
ā āā catch()
ā āā sandbox()
ā āā safeJson()
ā āā timeLimit()
ā āā cancelable()
ā
āā Input/Output Transformation
ā āā validate()
ā āā mask()
ā āā restrict()
ā āā tap()
ā āā transformOutput()
ā āā locale()
ā āā unit()
ā
āā Caching & Memoization
ā āā memo()
ā āā replay()
ā
āā Functional Composition
ā āā pipe()
ā āā chainable()
ā
āā Retry & Simulation
ā āā retry()
ā āā simulate()
ā āā randomBehavior()
ā āā randomizeArgs()
ā
āā Undo & History
ā āā undoable()
ā āā history()
ā
āā Conditional Execution
ā āā ensure()
ā āā filterArgs()
ā āā delayIf()
ā āā alertOn()
ā āā warnOnArgs()
ā āā predict()
ā āā eventual()
ā
āā Repeat & Batch
ā āā repeat()
ā āā batch()
ā
āā Miscellaneous
āā hook()
āā evolve()
FunctionWrapper
āā Logging & Monitoring
ā āā log(fn)
ā āā time(fn)
ā āā profile(fn)
ā āā changelog(fn)
ā āā feedback(fn, logger)
ā āā watch(fn)
ā
āā Execution Control
ā āā once(fn)
ā āā after(fn, n)
ā āā before(fn, n)
ā āā lock(fn)
ā āā queue(fn)
ā āā repeat(fn, n)
ā āā delayFn(fn, delay)
ā āā timeLimit(fn, timeout)
ā āā sandbox(fn, timeout)
ā āā afterIdle(fn, timeout)
ā āā smartIdle(fn, options)
ā
āā Error Handling & Safety
ā āā catch(fn, onError, fallback)
ā āā safeJson(fn)
ā āā undoable(fn, inverseFn)
ā āā cancelable(fn)
ā āā ensure(fn, validator)
ā āā restrict(fn, isAllowed)
ā
āā Input/Output Transformation
ā āā tap(fn, tapFn)
ā āā mask(fn, masker)
ā āā transformOutput(fn, transformer)
ā āā evolve(fn, evolver)
ā āā locale(fn, formatter)
ā āā randomizeArgs(fn)
ā āā randomBehavior(fn, behaviors)
ā āā predict(fn, modelFn)
ā
āā Caching & Memoization
ā āā memo(fn)
ā āā replay(fn)
ā āā oncePerArgs(fn)
ā
āā Functional Composition
ā āā chainable(fn)
ā āā pipe(...fns)
ā āā hook(fn, {before, after})
ā
āā Retry & Simulation
ā āā retry(fn, retries, delayMs)
ā āā simulate(fn, {failRate, corrupt, delay})
ā
āā Conditional Execution
ā āā delayIf(fn, condition, delayMs)
ā āā eventual(fn, checkFn, interval)
ā āā filterArgs(fn, filterFn)
ā āā warnOnArgs(fn, warningFn)
ā āā alertOn(fn, condition)
ā
āā Repeat & Batch
ā āā batch(fn, chunkSize, cb)
ā āā delayEach(fn, delayMs)
ā
āā Unit & Stats
āā unit(fn, unit)
āā stats(fn)