π FunctionWrapper
FunctionWrapper is a highly versatile utility class for JavaScript/TypeScript functions that allows you to enhance, monitor, transform, and control functions with a rich set of composable decorators. It extends a Logger base class to provide optional logging capabilities.
With FunctionWrapper, you can chain multiple function transformations, handle retries, measure performance, debounce or throttle calls, enforce validations, create undoable operations, and much moreβall in a highly modular and chainable manner.
Features
FunctionWrapper provides over 80+ static methods to extend and wrap functions. Some of the core capabilities include:
-
Logging and Monitoring
log(fn): Logs function calls and results.time(fn): Measures execution duration.profile(fn): Logs execution stats with timestamp.stats(fn): Tracks call count and average execution time.
-
Control Flow Enhancements
retry(fn, retries, delayMs): Automatically retries a function on failure.once(fn),oncePerArgs(fn): Execute only once globally or per argument set.after(fn, n),before(fn, n): Control execution after or before a number of calls.limit(fn, max): Limits total number of calls.lock(fn): Prevents concurrent execution.
-
Asynchronous Handling
debounce(fn, wait): Delays execution until idle.throttle(fn, wait): Limits execution frequency.delayFn(fn, delay),delayResult(fn, ms),delayEach(fn, ms): Flexible delayed execution.cancelable(fn): Creates cancelable promises.queue(fn): Serializes asynchronous calls.
-
Data Manipulation
memo(fn): Caches results for identical arguments.transformOutput(fn, transformer): Post-process function results.mask(fn, masker): Preprocess arguments before calling the function.randomizeArgs(fn): Shuffles arguments randomly.randomBehavior(fn, behaviors): Introduces probabilistic behaviors.
-
Validation and Safety
validate(fn, validator): Validates arguments.ensure(fn, validator): Validates output.catch(fn, onError, fallback): Graceful error handling.sandbox(fn, timeout): Safe execution with error handling and time limit.safeJson(fn): Safe JSON parsing and handling.
-
Functional Utilities
chain(fn): Chain multiple transformations in a fluent interface.pipe(...fns): Compose functions in a pipeline.tap(fn, tapFn): Tap into function results without affecting output.hook(fn, { before, after }): Run pre- and post-execution hooks.feedback(fn, logger): Collect input/output logs.
-
Simulation and Testing
simulate(fn, options): Simulate failures, delays, and data corruption.test(fn, testCases): Run predefined tests on a function.predict(fn, modelFn): Attach predictive models to results.
-
Batching and History
batch(fn, chunkSize, cb): Execute functions in batches.history(fn): Track inputs and outputs withgetHistoryandclearHistory.watch(fn): Subscribe to function call results.changelog(fn): Track changes in object outputs.
-
Advanced Features
undoable(fn, inverseFn): Support undo operations.locale(fn, formatter): Apply locale-based input/output formatting.smartIdle(fn, options): Execute during idle periods with cancellation.eventual(fn, checkFn, interval): Poll until a condition is met.timeLimit(fn, timeout): Force a maximum execution duration.
Installation
1npm install hbh-nodes
Or using yarn:
1yarn add hbh-nodes
Import
1import { FunctionWrapper as FW } from "hbh-nodes";2const { FunctionWrapper } = FW;
Usage
1. Basic Function Wrapping
1const add = (a, b) => a + b;2const loggedAdd = FunctionWrapper.log(add);4console.log(loggedAdd(2, 3));5// Logs: Calling add [2, 3]6// Logs: Result from add 5
2. Chaining Transformations
1const multiply = (a, b) => a * b;3const enhancedFn = FunctionWrapper.chain(multiply)4 .log()5 .time()6 .memo()7 .value();9console.log(enhancedFn(5, 6));
3. Debounce / Throttle
1const save = (data) => console.log('Saved:', data);2const debouncedSave = FunctionWrapper.debounce(save, 500);3const throttledSave = FunctionWrapper.throttle(save, 1000);
4. Retry with Delay
1const unstable = () => {2 if (Math.random() < 0.7) throw new Error('Fail');3 return 'Success';4};6const reliable = FunctionWrapper.retry(unstable, 5, 100);7reliable().then(console.log).catch(console.error);
5. Undoable Functions
1let counter = 0;2const increment = () => ++counter;3const decrement = () => --counter;5const undoableIncrement = FunctionWrapper.undoable(increment, decrement);6undoableIncrement(); // counter = 17undoableIncrement.undo(); // counter = 0
6. Monitoring and Stats
1const slowFn = (x) => new Promise(res => setTimeout(() => res(x * 2), 100));2const profiled = FunctionWrapper.stats(slowFn);4profiled(2).then(() => {5 console.log(profiled.stats); // { calls: 1, avgTime: '100.00ms' }6});
API Reference
Each static method of FunctionWrapper can be used independently to wrap any function. Refer to the method list in the Features section for full capabilities.
Chaining Example
1const fn = (x) => x * 2;2const chained = FunctionWrapper.chain(fn)3 .debounce(200)4 .log()5 .memo()6 .time()7 .value();9chained(5);
FunctionWrapper API Reference
FunctionWrapper is an advanced utility class that provides 80+ higher-order function decorators and wrappers for logging, timing, retrying, caching, debouncing, throttling, validating, transforming, and managing functions in versatile ways.
| Method | Parameters | Description | Usage Example | Output |
|---|---|---|---|---|
log(fn) |
fn: Function |
Logs function call and result | const add = (a,b)=>a+b; const loggedAdd = FunctionWrapper.log(add); loggedAdd(2,3); |
Logs: Calling add [2,3] Logs: Result from add 5 |
time(fn) |
fn: Function |
Measures execution time (async supported) | const slow = () => new Promise(res=>setTimeout(()=>res(42),100)); const timed = FunctionWrapper.time(slow); timed(); |
Logs: slow took 100.00 ms |
retry(fn, retries=3, delayMs=0) |
fn: Function, retries?: number, delayMs?: number |
Retries a failing function up to retries times with optional delay |
const unstable = ()=>{ if(Math.random()<0.7) throw Error('Fail'); return 'Ok'; }; const reliable = FunctionWrapper.retry(unstable,5,100); reliable().then(console.log) |
Either 'Ok' or error if all retries fail |
memo(fn) |
fn: Function |
Caches function results based on arguments | const square = x=>x*x; const cached = FunctionWrapper.memo(square); cached(2); cached(2); |
Only first call computes, second returns cached value |
debounce(fn, wait=300) |
fn: Function, wait?: number |
Delays execution until wait ms of inactivity |
const save = x=>console.log('Saved',x); const dSave = FunctionWrapper.debounce(save,500); dSave(1); dSave(2); |
Only 'Saved 2' after 500ms |
throttle(fn, wait=300) |
fn: Function, wait?: number |
Ensures function executes at most once per wait ms |
const log = x=>console.log(x); const tLog = FunctionWrapper.throttle(log,500); tLog(1); tLog(2); |
Executes 1 immediately, 2 after 500ms |
validate(fn, validator) |
fn: Function, validator: Function |
Validates arguments before calling | const sum = (a,b)=>a+b; const validated = FunctionWrapper.validate(sum,args=>{if(args.some(x=>typeof x!=='number'))throw Error('Invalid');}); validated(1,2); |
Returns 3 |
catch(fn, onError, fallback=null) |
fn: Function, onError?: Function, fallback?: any |
Catches errors, calls onError, optionally returns fallback |
const fail = ()=>{throw Error('Oops')}; const safe = FunctionWrapper.catch(fail,e=>console.log(e.message),'F'); safe(); |
Logs 'Oops' and returns 'F' |
once(fn) |
fn: Function |
Executes function only once globally | const inc=()=>1; const onceInc=FunctionWrapper.once(inc); onceInc(); onceInc(); |
Returns 1 both calls, only first actually executes |
after(fn, n=1) |
fn: Function, n?: number |
Executes function after n calls |
const log=()=>console.log('Hello'); const after2=FunctionWrapper.after(log,2); after2(); after2(); |
Logs 'Hello' on second call |
before(fn, n=1) |
fn: Function, n?: number |
Executes function at most n times |
const log=()=>console.log('Hi'); const b4=FunctionWrapper.before(log,2); b4(); b4(); b4(); |
Logs 'Hi' twice, third call returns null |
delayFn(fn, delay=1000) |
fn: Function, delay?: number |
Executes function after a delay | const say=()=>console.log('Hi'); const delayed=FunctionWrapper.delayFn(say,500); delayed(); |
Logs 'Hi' after 500ms |
timeLimit(fn, timeout=1000) |
fn: Function, timeout?: number |
Rejects if execution exceeds timeout | const slow=()=>new Promise(res=>setTimeout(()=>res(1),1500)); FunctionWrapper.timeLimit(slow,1000) |
Throws 'Timeout exceeded' |
tap(fn, tapFn) |
fn: Function, tapFn: Function |
Executes tapFn with function result without affecting it |
const double=x=>x*2; const tapped=FunctionWrapper.tap(double,r=>console.log('Tap',r)); tapped(3); |
Logs 'Tap 6', returns 6 |
restrict(fn, isAllowed) |
fn: Function, isAllowed: Function |
Throws if isAllowed returns false |
const secret=()=>42; const restricted=FunctionWrapper.restrict(secret,()=>false); restricted(); |
Throws 'Access denied' |
lock(fn) |
fn: Function |
Prevents concurrent execution | const sleep=x=>new Promise(res=>setTimeout(res,x)); const locked=FunctionWrapper.lock(sleep); locked(100); locked(100); |
Second call throws 'Already running' |
history(fn) |
fn: Function |
Tracks inputs and outputs | const add=(a,b)=>a+b; const h=FunctionWrapper.history(add); h(1,2); h.getHistory(); |
Returns [ { args:[1,2], result:3 } ] |
watch(fn) |
fn: Function |
Allows subscribing to results | const add=(a,b)=>a+b; const w=FunctionWrapper.watch(add); w.subscribe((args,res)=>console.log('Watched',res)); w(2,3); |
Logs 'Watched 5' |
mask(fn, masker) |
fn: Function, masker: Function |
Transforms arguments before calling | const sum=(a,b)=>a+b; const masked=FunctionWrapper.mask(sum,args=>args.map(x=>x*2)); masked(1,2); |
Returns 6 |
cancelable(fn) |
fn: Function |
Returns a cancelable promise | const p=()=>new Promise(res=>setTimeout(()=>res(1),500)); const c=FunctionWrapper.cancelable(p); const promise=c(); promise.cancel(); |
Rejects with 'Cancelled' |
limit(fn, max=5) |
fn: Function, max?: number |
Limits number of executions | const log=x=>x; const limited=FunctionWrapper.limit(log,2); limited(1); limited(2); limited(3); |
Third call throws 'Limit exceeded' |
rateTracker(fn, windowMs=1000) |
fn: Function, windowMs?: number |
Tracks number of calls in sliding window | const add=(a,b)=>a+b; const tracked=FunctionWrapper.rateTracker(add); tracked(1,2); |
Result object has _rate property |
replay(fn) |
fn: Function |
Returns cached result for identical arguments | const f=x=>x*2; const r=FunctionWrapper.replay(f); r(2); r(2); |
Returns 4 both times, second call uses cached result |
safeJson(fn) |
fn: Function |
Wraps function to catch JSON errors | const parse=JSON.parse; const safeParse=FunctionWrapper.safeJson(parse); safeParse('invalid'); |
Returns { error: 'Invalid JSON', details: ... } |
profile(fn) |
fn: Function |
Logs execution stats in table | const slow=x=>new Promise(res=>setTimeout(()=>res(x),100)); FunctionWrapper.profile(slow)(5); |
Logs table with function name, duration, timestamp |
unit(fn, unit='') |
fn: Function, unit?: string |
Returns { value, unit, timestamp } |
const add=(a,b)=>a+b; const u=FunctionWrapper.unit(add,'ms'); u(1,2); |
{ value:3, unit:'ms', timestamp: 12345678 } |
changelog(fn) |
fn: Function |
Logs changes in object output | const obj=()=>({x:Math.random()}); const c=FunctionWrapper.changelog(obj); c(); c(); |
Logs only changes |
undoable(fn, inverseFn) |
fn: Function, inverseFn: Function |
Supports undo operation | let x=0; const inc=()=>x++; const dec=()=>x--; const u=FunctionWrapper.undoable(inc,dec); u(); u.undo(); |
x returns to previous state |
feedback(fn, logger) |
fn: Function, logger?: Function |
Logs input/output with custom logger | const add=(a,b)=>a+b; const f=FunctionWrapper.feedback(add); f(1,2); |
Logs { input:[1,2], output:3 } |
locale(fn, formatter) |
fn: Function, formatter?: {input?: fn, output?: fn} |
Formats input/output | const add=(a,b)=>a+b; const loc=FunctionWrapper.locale(add,{output:r=>'Result:'+r}); loc(1,2); |
Returns 'Result:3' |
queue(fn) |
fn: Function |
Executes function sequentially | const sleep=x=>new Promise(res=>setTimeout(()=>res(x),100)); const q=FunctionWrapper.queue(sleep); q(1); q(2); |
Second call waits until first finishes |
repeat(fn, n=1) |
fn: Function, n?: number |
Calls function n times, returns array of results |
const f=x=>x*2; FunctionWrapper.repeat(f,3)(2); |
[4,4,4] |
test(fn, testCases=[]) |
fn: Function, testCases:Array<[input,expected]> |
Runs test cases | const add=(a,b)=>a+b; FunctionWrapper.test(add,[[ [1,2],3 ]])(); |
[ { input:[1,2], expected:3, result:3, passed:true } ] |
delayResult(fn, ms=1000) |
fn: Function, ms?: number |
Returns result after delay | const f=x=>x+1; FunctionWrapper.delayResult(f,500)(2); |
Returns 3 after 500ms |
ensure(fn, validator) |
fn: Function, validator: Function |
Throws if output fails validation | const f=x=>x*2; const e=FunctionWrapper.ensure(f,r=>r<5); e(2); e(3); |
Throws on second call |
randomizeArgs(fn) |
fn: Function |
Shuffles arguments randomly before calling | const f=(a,b)=>[a,b]; FunctionWrapper.randomizeArgs(f)(1,2); |
Returns [2,1] or [1,2] |
randomBehavior(fn, behaviors=[]) |
fn: Function, behaviors: Function[] |
Executes one of the random behaviors | const f=x=>x; const b=[(fn,args)=>fn(...args)*2]; FunctionWrapper.randomBehavior(f,b)(2); |
Returns 4 |
transformOutput(fn, transformer) |
fn: Function, transformer: Function |
Transforms function output | const f=x=>x+1; FunctionWrapper.transformOutput(f,r=>r*2)(2); |
Returns 6 |
evolve(fn, evolver) |
fn: Function, evolver: Function |
Mutates or extends output | const f=()=>({a:1}); FunctionWrapper.evolve(f,{b:2})(); |
{ a:1, b:2 } |
simulate(fn, {failRate=0.1, corrupt=false, delay=300}) |
fn: Function, options |
Simulates failures, delays, and corruption | const f=x=>x; FunctionWrapper.simulate(f,{failRate:1})(1) |
Throws 'Simulated Failure' |
chainable(fn) |
fn: Function |
Allows chaining calls and collecting results | const f=x=>x*2; const c=FunctionWrapper.chainable(f); c(1)(2).value(); |
Returns [2,4] |
predict(fn, modelFn) |
fn: Function, modelFn: Function |
Adds prediction based on function output | const f=x=>x*2; const p=FunctionWrapper.predict(f,r=>r+1); p(2); |
{ result:4, prediction:5 } |
delayIf(fn, condition, delayMs=1000) |
fn: Function, condition: Function, delayMs?: number |
Delays execution if condition is true | const f=x=>x; FunctionWrapper.delayIf(f,x=>x>0,500)(1); |
Returns 1 after 500ms |
eventual(fn, checkFn, interval=100) |
fn: Function, checkFn: Function, interval?: number |
Polls until checkFn returns true | const f=x=>x; FunctionWrapper.eventual(f,()=>true)(); |
Resolves immediately |
pipe(...fns) |
fns: Function[] |
Composes multiple functions left to right | FunctionWrapper.pipe(x=>x+1,x=>x*2)(2); |
Returns (2+1)*2 = 6 |
filterArgs(fn, filterFn) |
fn: Function, filterFn: Function |
Calls fn only if filterFn returns true | const f=x=>x; FunctionWrapper.filterArgs(f,x=>x>0)(-1); |
Returns null |
warnOnArgs(fn, warningFn) |
fn: Function, warningFn: Function |
Warns if warningFn returns true | const f=x=>x; FunctionWrapper.warnOnArgs(f,x=>x<0)(-1); |
Logs warning, returns -1 |
oncePerArgs(fn) |
fn: Function |
Executes once per argument combination | const f=x=>x; FunctionWrapper.oncePerArgs(f)(1); FunctionWrapper.oncePerArgs(f)(1); |
Returns 1, then null |
alertOn(fn, condition) |
fn: Function, condition: Function |
Alerts if condition on result is true | const f=x=>x; FunctionWrapper.alertOn(f,r=>r>0)(1); |
Logs alert, returns 1 |
hook(fn, { before, after }) |
fn: Function, before?: Function, after?: Function |
Adds pre- and post-execution hooks | const f=x=>x*2; FunctionWrapper.hook(f,{before:x=>console.log('Before',x),after:(r)=>console.log('After',r)})(2); |
Logs 'Before 2', 'After 4', returns 4 |
delayEach(fn, delayMs=300) |
fn: Function, delayMs?: number |
Calls function for each argument sequentially with delay | const f=x=>x*2; FunctionWrapper.delayEach(f,100)(1,2,3); |
Returns [2,4,6] over 100ms intervals |
sandbox(fn, timeout=1000) |
fn: Function, timeout?: number |
Executes safely with error handling | const f=()=>{throw Error('Fail')}; FunctionWrapper.sandbox(f)(); |
Logs 'Sandbox Error: Fail', returns undefined |
afterIdle(fn, timeout=0) |
fn: Function, timeout?: number |
Executes when browser idle | FunctionWrapper.afterIdle(()=>console.log('Idle'),500) |
Logs 'Idle' after idle period |
smartIdle(fn, {timeout=1000}) |
fn: Function, options |
Idle execution with cancellation | const f=x=>x; const s=FunctionWrapper.smartIdle(f); s(1); s.cancel(); |
Cancels execution if idle hasn't started |
| Method | Purpose |
|---|---|
log(fn) |
Logs function calls and results |
profile(fn) |
Measures execution time, logs stats |
changelog(fn) |
Logs differences between successive outputs |
feedback(fn, logger) |
Logs input/output with optional custom logger |
warnOnArgs(fn, warningFn) |
Warns if arguments meet suspicious condition |
alertOn(fn, condition) |
Alerts if output meets condition |
| Method | Purpose |
|---|---|
time(fn) |
Measures execution time (async supported) |
timeLimit(fn, timeout) |
Throws if execution exceeds timeout |
delayFn(fn, delay) |
Delays execution by specified ms |
delayResult(fn, ms) |
Returns result after delay |
delayEach(fn, delayMs) |
Sequentially calls function on multiple args with delay |
delayIf(fn, condition, delayMs) |
Delays execution if condition is true |
afterIdle(fn, timeout) |
Executes when browser is idle |
smartIdle(fn, {timeout}) |
Idle execution with cancellation support |
| Method | Purpose |
|---|---|
retry(fn, retries, delayMs) |
Retries function on failure |
once(fn) |
Executes only once |
lock(fn) |
Prevents concurrent executions |
queue(fn) |
Ensures sequential execution |
cancelable(fn) |
Returns cancelable promise |
sandbox(fn, timeout) |
Safe async execution with error handling |
eventual(fn, checkFn, interval) |
Polls until a condition is true |
simulate(fn, options) |
Simulates failures, delays, or corrupted outputs |
| Method | Purpose |
|---|---|
memo(fn) |
Caches results by arguments |
replay(fn) |
Returns cached result for identical args |
oncePerArgs(fn) |
Executes once per unique args |
history(fn) |
Tracks inputs and outputs |
tap(fn, tapFn) |
Allows side effects without changing output |
| Method | Purpose |
|---|---|
validate(fn, validator) |
Validates arguments before execution |
ensure(fn, validator) |
Validates output |
restrict(fn, isAllowed) |
Throws if access is denied |
| Method | Purpose |
|---|---|
debounce(fn, wait) |
Executes only after idle period |
throttle(fn, wait) |
Limits execution rate |
rateTracker(fn, windowMs) |
Tracks call frequency |
| Method | Purpose |
|---|---|
pipe(...fns) |
Composes multiple functions |
transformOutput(fn, transformer) |
Transforms result |
evolve(fn, evolver) |
Mutates output |
randomizeArgs(fn) |
Randomly shuffles arguments |
randomBehavior(fn, behaviors) |
Executes random behavior |
| Method | Purpose |
|---|---|
batch(fn, chunkSize, cb) |
Calls function in chunks |
repeat(fn, n) |
Calls function multiple times |
| Method | Purpose |
|---|---|
after(fn, n) |
Executes after n calls |
before(fn, n) |
Executes at most n times |
hook(fn, {before, after}) |
Hooks before/after execution |
undoable(fn, inverseFn) |
Supports undo operations |
chainable(fn) |
Allows chaining multiple calls |
pipe(...fns) |
Composes functions in sequence |
| Method | Purpose |
|---|---|
test(fn, testCases) |
Runs test cases |
simulate(fn, {failRate, corrupt, delay}) |
Simulates failures and delays |
predict(fn, modelFn) |
Adds predictions based on output |
| Method | Purpose |
|---|---|
unit(fn, unit) |
Wraps output with value, unit, timestamp |
mask(fn, masker) |
Masks or transforms arguments |
locale(fn, formatter) |
Localizes input/output |
Perfect! Letβs make a detailed mental map / diagram of the entire FunctionWrapper class and its methods. Iβll structure it clearly so you can either visualize it or later draw it on paper/software.
-
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)