| 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.