Native import
import Stack from 'js-queue/stack';Modern LIFO entry
js-queue/stack exposes easy-stack 2.1.0 for last-in-first-out execution with the same Node 22.13 baseline.
Load it explicitly
The queue core is FIFO. Import the stack entry only when the most recently added task should execute first.
import Stack from 'js-queue/stack';const Stack=require('js-queue/stack.js');const stack=new Stack;
stack.autoRun=false;
stack.add(first,second,third);
stack.next(); // third runs firstChoose the order
Both structures use explicit next() hand-offs, but they remove pending work from opposite ends.
| Property | Queue | Stack |
|---|---|---|
| Order | First in, first out | Last in, first out |
| Entry | js-queue | js-queue/stack |
| Removes | Front via array shift | Back via array pop |
| Best fit | Requests, messages, ordered pipelines | Undo-like work, nested traversal, newest-first priority |
| State surface | contents, size, running | stack, contents(), size, running |
easy-stack 2.1.0 uses private instance fields and one shared Node module for native ESM and CommonJS while preserving its public flow contract. See the focused easy-stack documentation for its complete API and benchmark.
Need predictable arrival order instead?
Start with Queue