{"name":"easy-stack","version":"2.0.0","keywords":["stack","lifo","scheduler","priority","javascript","node","browser","zero-dependency"],"author":{"name":"Brandon Nozaki Miller"},"license":"MIT","_id":"easy-stack@2.0.0","maintainers":[{"name":"riaevangelist","email":"brandon@diginow.it"}],"homepage":"https://riaevangelist.github.io/easy-stack/","bugs":{"url":"https://github.com/RIAEvangelist/easy-stack/issues"},"dist":{"shasum":"62eecc80c8726023372e49ebf95d5c5223093ffb","tarball":"http://registry-npm.ywwl.com/easy-stack/download/easy-stack-2.0.0.tgz","fileCount":9,"integrity":"sha512-kr6rWL48jxaM0+n+m3FhtJ5is30WWFo6zu3JY2e4ztbW423/GlVav8Li6b71gmDnAh99zHsagsvAFmJPlIBr0A==","signatures":[{"sig":"MEUCIQCwYbvmyKXTWrThUz+n2MTX/4Kgtj4fvbt0b53SSdcynQIgL/FrRNDE2G3IjA5Isr7ACK3KEfrEQpQxUXsE9GRbob0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIQDjvazEBCiuX01GB6caajdiHgO85V7u4L3emXMeM2RZOQIgfBFhqqJ2gsmWQEsq2ZWbtF3UpLojxTcu3u5arN8dzcU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21905,"size":6098,"noattachment":false,"key":"/easy-stack/-/easy-stack-2.0.0.tgz"},"main":"./stack.cjs","type":"module","module":"./stack.js","browser":"./stack.js","engines":{"node":">=12.22.0"},"exports":{".":{"import":"./stack.js","default":"./stack.js","require":"./stack.cjs"},"./es5.js":{"import":"./stack.js","default":"./es5.js","require":"./stack.cjs"},"./stack.js":{"import":"./stack.js","default":"./stack.js","require":"./stack.cjs"},"./package.json":"./package.json","./stack-vanilla.js":"./stack-vanilla.js"},"gitHead":"9bb6148b2934d9885bfc48199c02d121a7e25afd","scripts":{"test":"node ./scripts/test.js","check":"npm test && npm run coverage:node","start":"node ./scripts/serve.js","coverage":"vanilla-test coverage","test:core":"node ./scripts/test.js core","test:docs":"node ./scripts/test.js docs","test:legacy":"node ./scripts/test.js legacy","test:server":"node ./scripts/test.js server","test:package":"node ./scripts/test.js package","coverage:node":"vanilla-test coverage node","coverage:chrome":"vanilla-test coverage chrome"},"_npmUser":{"name":"riaevangelist","email":"brandon@diginow.it"},"repository":{"url":"git+https://github.com/RIAEvangelist/easy-stack.git","type":"git"},"_npmVersion":"11.16.0","description":"Zero-dependency cooperative LIFO execution for Node.js and browsers","directories":{},"sideEffects":["./stack-vanilla.js","./es5.js"],"_nodeVersion":"24.18.0","_hasShrinkwrap":false,"devDependencies":{"vanilla-test":"2.1.1"},"_npmOperationalInternal":{"tmp":"tmp/easy-stack_2.0.0_1786898324496_0.8603195567343063","host":"s3://npm-registry-packages-npm-production"},"readme":"[![easy-stack — explicit LIFO flow control for JavaScript](https://raw.githubusercontent.com/RIAEvangelist/easy-stack/main/assets/easy-stack-header.png)](https://riaevangelist.github.io/easy-stack/)\n\n# easy-stack\n\nZero-dependency cooperative LIFO execution for Node.js and browsers.\n\n[Overview](https://riaevangelist.github.io/easy-stack/) · [Why easy-stack](https://riaevangelist.github.io/easy-stack/why/) · [Guide](https://riaevangelist.github.io/easy-stack/guide/) · [API](https://riaevangelist.github.io/easy-stack/api/) · [Patterns](https://riaevangelist.github.io/easy-stack/patterns/) · [Browser](https://riaevangelist.github.io/easy-stack/browser/) · [Examples](https://riaevangelist.github.io/easy-stack/examples/) · [Playground](https://riaevangelist.github.io/easy-stack/playground/) · [Stack vs queue](https://riaevangelist.github.io/easy-stack/queue/) · [Benchmarks](https://riaevangelist.github.io/easy-stack/benchmarks/) · [Migration](https://riaevangelist.github.io/easy-stack/migration/) · [Testing](https://riaevangelist.github.io/easy-stack/testing/)\n\n[![npm version](https://img.shields.io/npm/v/easy-stack?logo=npm)](https://www.npmjs.com/package/easy-stack)\n[![npm downloads](https://img.shields.io/npm/dm/easy-stack?logo=npm)](https://www.npmjs.com/package/easy-stack)\n[![Node.js support](https://img.shields.io/badge/node-%3E%3D22.13-339933?logo=nodedotjs&logoColor=white)](https://riaevangelist.github.io/easy-stack/testing/)\n[![CI](https://github.com/RIAEvangelist/easy-stack/actions/workflows/ci.yml/badge.svg)](https://github.com/RIAEvangelist/easy-stack/actions/workflows/ci.yml)\n[![test cases](https://img.shields.io/badge/test_cases-94_unique-12d9c4)](https://riaevangelist.github.io/easy-stack/testing/)\n[![test runner](https://img.shields.io/badge/test_runner-vanilla--test%202.1.1-12d9c4)](https://riaevangelist.github.io/easy-stack/testing/)\n[![coverage](https://img.shields.io/badge/coverage-100%25-12d9c4)](https://riaevangelist.github.io/easy-stack/testing/)\n[![runtime dependencies](https://img.shields.io/badge/runtime_dependencies-0-12d9c4)](https://www.npmjs.com/package/easy-stack?activeTab=dependencies)\n[![license](https://img.shields.io/npm/l/easy-stack)](./licence)\n\n## Quick start\n\n```sh\nnpm install easy-stack\n```\n\n```javascript\nimport Stack from 'easy-stack';\n\nconst stack = new Stack();\nconst order = [];\n\nstack.autoRun = false;\nstack.add(\n    function first() {\n        order.push('first');\n        this.next();\n    },\n    function newest() {\n        order.push('newest');\n        this.next();\n    }\n);\nstack.next();\n\nconsole.log(order); // ['newest', 'first']\n```\n\nCommonJS remains supported:\n\n```javascript\nconst Stack = require('easy-stack');\n```\n\nBoth loaders resolve the same synchronous `stack.js` implementation on Node 22.13 and newer.\n\nEach task receives the stack as `this` and explicitly continues the flow with `this.next()`. Execution begins synchronously when `autoRun` is truthy; set it to `false` while assembling a batch.\n\n## Contract at a glance\n\n| API | Result |\n| --- | --- |\n| `new Stack()` | Creates an isolated stack with `autoRun = true` and `stop = false`. |\n| `add(...tasks)` | Validates and appends functions, starts eligible work, and returns the stack. |\n| `next()` | Runs the newest pending task and returns `undefined`. |\n| `clear()` | Removes pending work and returns the new empty live array. |\n| `contents()` | Returns the live pending array. |\n| `contents(tasks)` | Replaces pending work after validating the complete array. |\n| `stack` | Gets or replaces the live pending array. |\n| `size` | Reports the pending task count. |\n| `running` | Reports whether a task has started and not yet yielded or drained. |\n\nThe runner is intentionally cooperative. A task that does not call `this.next()` keeps the stack active until another part of the program calls `next()`. New tasks added while active take priority over older pending work.\n\n## Why choose it\n\nChoose easy-stack when the newest pending intent should run first and the active task should control the hand-off. It has zero runtime dependencies, exposes pending work for inspection, works in Node and browsers, and keeps its behavior small enough to verify exhaustively. Use a FIFO queue, concurrency pool, or durable job broker when those are the actual requirements.\n\nRead the focused [selection guide](https://riaevangelist.github.io/easy-stack/why/) and [version benchmarks](https://riaevangelist.github.io/easy-stack/benchmarks/).\n\n[![easy-stack 2.1.0 benchmark chart showing about 18 times faster construction and 1.57 to 2.40 times faster task-turn scheduling](https://raw.githubusercontent.com/RIAEvangelist/easy-stack/main/assets/benchmark-chart.svg)](https://riaevangelist.github.io/easy-stack/benchmarks/)\n\nCaptured microbenchmarks compare the exact 2.0.0 WeakMap runtime with 2.1.0 private fields. See the linked page for the complete method, exact timings, machine data, and reproduction command.\n\n## Browser entry points\n\neasy-stack works with bundlers and without a bundler. Bundlers resolve the bare `easy-stack` import normally. Native browser ESM resolves that same bare import through an import map, with no build or transpilation step:\n\n```html\n<script type=\"importmap\">\n{\n    \"imports\": {\n        \"easy-stack\": \"./node_modules/easy-stack/stack.js\"\n    }\n}\n</script>\n<script type=\"module\">\n    import Stack from 'easy-stack';\n\n    const stack = new Stack();\n</script>\n```\n\nImport-map URLs are relative to the HTML document. Serve the page over HTTP(S), and configure the server to expose the mapped `node_modules` files; `file://` is not a supported path. easy-stack currently has zero runtime dependencies, so the complete normal-layout map needs only the package entry and no scoped nested-dependency map.\n\nAlternatively, use `stack-vanilla.js` as a modern classic script or `es5.js` for legacy syntax:\n\n```html\n<script src=\"https://unpkg.com/easy-stack@2.1.1/stack-vanilla.js\"></script>\n<script>\n    const stack = new Stack();\n</script>\n```\n\nSee the focused [browser guide](https://riaevangelist.github.io/easy-stack/browser/) for module and classic-script examples.\n\n## Verification\n\nThe non-duplicated catalog contains 94 uniquely identified Unit, Functional, Behavioral, Integration, and Regression cases, all registered through `vanilla-test@2.1.1`. The same shared JavaScript inventory imports `easy-stack` by package name in Node and real Chrome; Chrome resolves it through the configured native import map. CI proves the exact Node 22.13 floor and Node 24 across Linux, macOS, and Windows; it also verifies composite consumer outcomes, five rendered Playground journeys in real Chrome, same-constructor ESM/CommonJS interop, browser globals, the packed npm artifact, documentation and deployment contracts, the opaque Playground Worker, and 100% statement, branch, function, and line coverage.\n\n```sh\nnpm test\nnpm run test:unit\nnpm run test:functional\nnpm run test:behavioral\nnpm run test:behavioral:chrome\nnpm run test:integration\nnpm run test:regression\nnpm run test:regression:chrome\nnpm run coverage\nnpm run benchmark\n```\n\nRead the [testing evidence](https://riaevangelist.github.io/easy-stack/testing/) or the [v2 migration guide](./MIGRATION.md).\n\n## License\n\n[MIT](./licence) © Brandon Nozaki Miller\n","publish_time":1786898324571,"_cnpm_publish_time":1786898324571,"dist-tags":{"latest":"2.1.1"}}