easy-stack is a JavaScript library providing a simple Last-In, First-Out (LIFO) stack data structure, designed for both Node.js and browser environments. Its distinguishing feature is `autoRun`, which allows the stack to automatically execute newly added functions if it's not currently running or has not been forcibly stopped. This makes it suitable for managing prioritized operations, such as handling socket messages, processing async/sync tasks in a specific order, or creating extendable base classes for custom stack behaviors. The current stable version is 1.0.1, released primarily to update its licensing from the DBAD Public License to MIT. The package maintains a stable, albeit infrequent, release cadence, focusing on broad compatibility across various CommonJS loaders and vanilla browser usage, targeting Node.js environments from version 6.0.0 and above.
npm install easy-stackVerified import paths — ran on the pinned version, not inferred.
Demonstrates initializing a new easy-stack instance, adding functions to it, and the LIFO execution flow with `this.next()` for sequence control, including dynamic additions.
Review the new MIT license terms if your project's compliance depends on the previous DBAD license.
Assign a boolean value directly to `stack.stop` (e.g., `stack.stop = true;`) to control stack execution.
Always use `const Stack = require('easy-stack');` for Node.js and bundler environments. For browser, use a script tag or a bundler.Consider potential compatibility or security implications when using in highly modern Node.js environments. While functional, it might not integrate seamlessly with very recent ecosystem changes.
Ensure that every function passed to `stack.add` explicitly calls `this.next()` after its work is done, particularly after any asynchronous tasks, to maintain the execution flow.
For browser usage, include `es5.js` via a `<script>` tag (e.g., `<script src='./node_modules/easy-stack/es5.js'></script>`) to make `Stack` globally available.
Ensure functions passed to `stack.add` are regular functions or are explicitly bound to the stack instance if `this` context is critical (though `easy-stack` usually handles this correctly internally for regular functions).
To stop or resume the stack, assign a boolean value directly: `stack.stop = true;` (to stop) or `stack.stop = false;` (to resume).
No dependency data recorded yet.