Strictly LIFO
The most recently added callback is always the next callback selected.
Zero dependencies · Node + browser
easy-stack is a small cooperative LIFO runner for priority work, staged requests, and flows where the most recently added task should execute next. It works with bundlers and without a bundler: bundlers resolve the package name normally, while native browser ESM uses an import map with no build or transpilation step.
npm install easy-stack
The execution contract
The v2.1 package keeps the original cooperative model, removes WeakMap overhead, and gives native ESM and CommonJS one shared Node implementation.
The most recently added callback is always the next callback selected.
Each callback decides when the flow continues by calling this.next().
With auto-run enabled, the first eligible task begins before add() returns.
A thrown callback error returns the runner to idle without swallowing the error.
Focused documentation
Pick the page that matches the work in front of you. Each route stays short enough to scan and complete.
Match its newest-first contract to the work you actually need to run.
Start hereInstall, import, and run a first cooperative stack.
ContractMethods, state, return values, validation, and errors.
DesignPriority insertion, pause gates, async hand-offs, and recovery.
WebNative modules, classic scripts, ES5 compatibility, and serving.
PracticeAdapt focused recipes, then continue in the interactive Playground.
ExperimentEdit and run isolated LIFO scenarios directly in the browser.
CompareDecide whether newest-first or oldest-first fits your workload.
MeasureReproduce the version-to-version private-state performance evidence.
UpgradeKeep compatibility while adopting modern entry points.
EvidenceSee the vanilla-test suites, coverage gates, package smoke, and CI matrix.
SourceInspect the implementation, report an issue, or contribute.