runAll
Problem
You have a list of cleanup or teardown functions and need to run all of them even if some throw — collecting errors rather than stopping at the first failure.
Solution
Use runAll(fns, options?) to execute all functions and throw an AggregateError at the end if any failed.
ts
import { runAll } from '@vielzeug/arsenal';
const cleanups = [() => closeDatabase(), () => clearCache(), () => flushLogs()];
runAll(cleanups); // all three run; throws AggregateError if any failReverse order (LIFO teardown)
ts
import { runAll } from '@vielzeug/arsenal';
runAll(cleanups, { reverse: true }); // runs last → firstPitfalls
- All functions run regardless of failures. The thrown
AggregateError.errorsarray contains each individual error.