{"_id":"@bananaseed/event_stream","_rev":"6-ff556c018522d2b06f31f7e63232ac6a","name":"@bananaseed/event_stream","dist-tags":{"latest":"1.3.1"},"versions":{"1.0.0":{"name":"@bananaseed/event_stream","version":"1.0.0","keywords":[],"author":{"name":"Ryan Childs"},"license":"MIT","_id":"@bananaseed/event_stream@1.0.0","maintainers":[{"name":"bananaseed","email":"bananaseedgames@gmail.com"}],"dist":{"shasum":"2cea2c274be09343ffa7c4840562532d5131c3a2","tarball":"https://registry.npmjs.org/@bananaseed/event_stream/-/event_stream-1.0.0.tgz","fileCount":10,"integrity":"sha512-kx0jgHLZuFcekqlM4XJkALwTNhWdqEsGs9IhUEiq+Cv+Eb13px36S0zRFGqxVPjzeMNLfiwIFltkxv2B5Yqyfw==","signatures":[{"sig":"MEUCIFqQTCwmarCj2UdqqWVK4nq8tVvbIZQM2sOyM1NPvFerAiEAzhJjFXg838Xb8IPgtJ4s8erAUSlGPsJZFxbtULUSDfM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":121177},"main":"dist/main.js","types":"dist/main.d.ts","module":"dist/main.mjs","source":"src/index.ts","scripts":{"build":"parcel build","check":"tsc --noEmit","watch":"parcel watch"},"_npmUser":{"name":"bananaseed","email":"bananaseedgames@gmail.com"},"_npmVersion":"11.7.0","description":"![npm version](https://img.shields.io/npm/v/@bananaseed/event_stream) ![license](https://img.shields.io/npm/l/@bananaseed/event_stream) ![minzipped size](https://img.shields.io/bundlephobia/minzip/@bananaseed/event_stream)","directories":{},"_nodeVersion":"23.6.1","_hasShrinkwrap":false,"devDependencies":{"parcel":"^2.16.3","typescript":"^5.9.3","@parcel/packager-ts":"^2.16.3","@parcel/transformer-typescript-types":"^2.16.3"},"_npmOperationalInternal":{"tmp":"tmp/event_stream_1.0.0_1768247630016_0.09372543868249439","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@bananaseed/event_stream","version":"1.0.1","keywords":[],"author":{"name":"Ryan Childs"},"license":"MIT","_id":"@bananaseed/event_stream@1.0.1","maintainers":[{"name":"bananaseed","email":"bananaseedgames@gmail.com"}],"dist":{"shasum":"7a4497b82c82f183005de08d49ac6b26e11df70e","tarball":"https://registry.npmjs.org/@bananaseed/event_stream/-/event_stream-1.0.1.tgz","fileCount":10,"integrity":"sha512-yVejHnkM+iRLt8oTN03D8nI+1rgQ1kTAgFrQGckOp70mPA1F4pFngP4P5vv1E3MVuJ6XVW89ARnoXMOTOwCT+w==","signatures":[{"sig":"MEUCIFxzy5T3Bk+A9PvyC5Zmv8VWa6kDHmxGnj7I1oEbFnU2AiEAhbDjQxKoI3jDLgv2sOpddRujNDrbt43JMfH70z/cGVY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":122653},"main":"dist/main.js","types":"dist/main.d.ts","module":"dist/main.mjs","source":"src/index.ts","gitHead":"eb5b824d1357fdd33617973a9d0a5f5d1e8eae21","scripts":{"build":"parcel build","check":"tsc --noEmit","watch":"parcel watch"},"_npmUser":{"name":"bananaseed","email":"bananaseedgames@gmail.com"},"_npmVersion":"11.11.0","description":"![npm version](https://img.shields.io/npm/v/@bananaseed/event_stream) ![license](https://img.shields.io/npm/l/@bananaseed/event_stream) ![minzipped size](https://img.shields.io/bundlephobia/minzip/@bananaseed/event_stream)","directories":{},"_nodeVersion":"23.6.1","_hasShrinkwrap":false,"devDependencies":{"parcel":"^2.16.3","typescript":"^5.9.3","@parcel/packager-ts":"^2.16.3","@parcel/transformer-typescript-types":"^2.16.3"},"_npmOperationalInternal":{"tmp":"tmp/event_stream_1.0.1_1773337308985_0.8933727407059506","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@bananaseed/event_stream","version":"1.0.2","keywords":[],"author":{"name":"Ryan Childs"},"license":"MIT","_id":"@bananaseed/event_stream@1.0.2","maintainers":[{"name":"bananaseed","email":"bananaseedgames@gmail.com"}],"dist":{"shasum":"86bd14a9859d72616c3b3fe28927cf8e11170018","tarball":"https://registry.npmjs.org/@bananaseed/event_stream/-/event_stream-1.0.2.tgz","fileCount":10,"integrity":"sha512-Kdn9CaJjGQ9Mba/VCDUgNG8mmKXEutduBdmoHoIRx6ppjQM3St4eGZvdmbMEdc5/QWqjQrYsjos0T2gOZuRqsg==","signatures":[{"sig":"MEUCIQC2d14BF5+SF+zN3k7mQyHG+gT4B8hoh4IclqxNBH8cbwIgW1Kaat4o1zVvmnPUNHf2tl7pDZM4lymwht+0zf+3bf4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":125221},"main":"dist/main.js","types":"dist/main.d.ts","module":"dist/main.mjs","source":"src/index.ts","gitHead":"d0d8e8950a1358ff2cb7207d747f7e6a074c6e83","scripts":{"build":"parcel build","check":"tsc --noEmit","watch":"parcel watch"},"_npmUser":{"name":"bananaseed","email":"bananaseedgames@gmail.com"},"_npmVersion":"11.11.0","description":"![npm version](https://img.shields.io/npm/v/@bananaseed/event_stream) ![license](https://img.shields.io/npm/l/@bananaseed/event_stream) ![minzipped size](https://img.shields.io/bundlephobia/minzip/@bananaseed/event_stream)","directories":{},"_nodeVersion":"23.6.1","_hasShrinkwrap":false,"devDependencies":{"parcel":"^2.16.3","typescript":"^5.9.3","@parcel/packager-ts":"^2.16.3","@parcel/transformer-typescript-types":"^2.16.3"},"_npmOperationalInternal":{"tmp":"tmp/event_stream_1.0.2_1774377225275_0.49996324276560355","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@bananaseed/event_stream","version":"1.2.0","keywords":[],"author":{"name":"Ryan Childs"},"license":"MIT","_id":"@bananaseed/event_stream@1.2.0","maintainers":[{"name":"bananaseed","email":"bananaseedgames@gmail.com"}],"homepage":"https://github.com/childsr/event_stream#readme","bugs":{"url":"https://github.com/childsr/event_stream/issues"},"dist":{"shasum":"b22c9ec794e1a1919c225a035ca8237276ed9537","tarball":"https://registry.npmjs.org/@bananaseed/event_stream/-/event_stream-1.2.0.tgz","fileCount":3,"integrity":"sha512-peFkTHrC7RGNwfhCc5YSpsz/8/w1phTN8Sr3w5rgehbMNZhdR5dcGcJv2FPF/SzpPv3jHb3/FajNABbzLfkceg==","signatures":[{"sig":"MEUCIEQ83rqqv4eSfdZSQ9nYxTGVbLnen5AG1SztT66lUIAsAiEAuWmIy7WbDr3Zq0yW9ADluy/EvgB/C+P9m/6znjemlzU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5445},"main":"dist/main.js","types":"dist/main.d.ts","module":"dist/main.mjs","source":"src/index.ts","gitHead":"453553af621210cc720492ba6789a9402b3b6786","scripts":{"test":"vitest","build":"vite build","check":"tsc --noEmit","watch":"vite build --watch","test:run":"vitest run"},"_npmUser":{"name":"bananaseed","email":"bananaseedgames@gmail.com"},"repository":{"url":"git+https://github.com/childsr/event_stream.git","type":"git"},"_npmVersion":"11.15.0","description":"![npm version](https://img.shields.io/npm/v/@bananaseed/event_stream) ![license](https://img.shields.io/npm/l/@bananaseed/event_stream) ![minzipped size](https://img.shields.io/bundlephobia/minzip/@bananaseed/event_stream)","directories":{},"_nodeVersion":"24.15.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^8.0.14","vitest":"^4.1.7","typescript":"^6.0.3","vite-plugin-dts":"^5.0.1","semantic-release":"^25.0.3"},"_npmOperationalInternal":{"tmp":"tmp/event_stream_1.2.0_1779914687648_0.017608768583410983","host":"s3://npm-registry-packages-npm-production"}},"1.3.0":{"name":"@bananaseed/event_stream","version":"1.3.0","keywords":[],"author":{"name":"Ryan Childs"},"license":"MIT","_id":"@bananaseed/event_stream@1.3.0","maintainers":[{"name":"bananaseed","email":"bananaseedgames@gmail.com"}],"homepage":"https://github.com/childsr/event_stream#readme","bugs":{"url":"https://github.com/childsr/event_stream/issues"},"dist":{"shasum":"5591a916710d0fd8df9b3db47e2e93d469ab2b04","tarball":"https://registry.npmjs.org/@bananaseed/event_stream/-/event_stream-1.3.0.tgz","fileCount":3,"integrity":"sha512-+dz2y/8EA7ytq7pSGGb4GO5wbXrqEm9duKfeM23Nh/csz/VllBYLweF5Aa6inG04Cgb5EAHDJlXad8WZRcxOtw==","signatures":[{"sig":"MEUCIB1nSy03+P4yDMylEqgiiNEBV3/lzfqL2Z7wTm3DODF8AiEAwpH1Br0iWj39FJ0whyi8l3iWSkaTGRSBk3dGN4NDbPM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5445},"main":"dist/main.js","types":"dist/main.d.ts","module":"dist/main.mjs","source":"src/index.ts","gitHead":"b7b93c1a8030c934445b9454ed752f5170658ffa","scripts":{"test":"vitest","build":"vite build","check":"tsc --noEmit","watch":"vite build --watch","test:run":"vitest run"},"_npmUser":{"name":"bananaseed","email":"bananaseedgames@gmail.com"},"repository":{"url":"git+https://github.com/childsr/event_stream.git","type":"git"},"_npmVersion":"11.15.0","description":"![npm version](https://img.shields.io/npm/v/@bananaseed/event_stream) ![license](https://img.shields.io/npm/l/@bananaseed/event_stream) ![minzipped size](https://img.shields.io/bundlephobia/minzip/@bananaseed/event_stream)","directories":{},"_nodeVersion":"24.16.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^8.0.14","vitest":"^4.1.7","typescript":"^6.0.3","vite-plugin-dts":"^5.0.1","semantic-release":"^25.0.3"},"_npmOperationalInternal":{"tmp":"tmp/event_stream_1.3.0_1780266578399_0.18687779569869822","host":"s3://npm-registry-packages-npm-production"}},"1.3.1":{"name":"@bananaseed/event_stream","version":"1.3.1","publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/childsr/event_stream.git"},"description":"![npm version](https://img.shields.io/npm/v/@bananaseed/event_stream) ![license](https://img.shields.io/npm/l/@bananaseed/event_stream) ![minzipped size](https://img.shields.io/bundlephobia/minzip/@bananaseed/event_stream)","source":"src/index.ts","main":"dist/main.js","module":"dist/main.mjs","types":"dist/main.d.ts","scripts":{"watch":"vite build --watch","build":"vite build","check":"tsc --noEmit","test":"vitest","test:run":"vitest run"},"keywords":[],"author":{"name":"Ryan Childs"},"license":"MIT","devDependencies":{"semantic-release":"^25.0.3","typescript":"^6.0.3","vite":"^8.0.14","vite-plugin-dts":"^5.0.1","vitest":"^4.1.7"},"gitHead":"5041785873fd9526d0a36cce1dd842df2e50b613","_id":"@bananaseed/event_stream@1.3.1","bugs":{"url":"https://github.com/childsr/event_stream/issues"},"homepage":"https://github.com/childsr/event_stream#readme","_nodeVersion":"24.16.0","_npmVersion":"11.15.0","dist":{"integrity":"sha512-l3V3oa4I7Or1EFxjpo65y7Lp4D8bqcQtsEd0/EnaUHH8Is2vErjqhhy6qeXnzy9vCMpP5Zi7j7lm3PoUyLIgyw==","shasum":"d81a236d6eacb7dab352f700286bbd7f974b5643","tarball":"https://registry.npmjs.org/@bananaseed/event_stream/-/event_stream-1.3.1.tgz","fileCount":8,"unpackedSize":94252,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDUzo4GImsaodzan/oQmmLDzZl+lTdPWv/p1fhoFXEi8gIhAJwPMUv06SvN0W852sFXpkUpIwG3IYirT2C8uLlJ2dGG"}]},"_npmUser":{"name":"bananaseed","email":"bananaseedgames@gmail.com"},"directories":{},"maintainers":[{"name":"bananaseed","email":"bananaseedgames@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/event_stream_1.3.1_1780266779158_0.9161052758159631"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-12T19:53:49.906Z","modified":"2026-05-31T22:32:59.387Z","1.0.0":"2026-01-12T19:53:50.160Z","1.0.1":"2026-03-12T17:41:49.203Z","1.0.2":"2026-03-24T18:33:45.443Z","1.2.0":"2026-05-27T20:44:47.780Z","1.3.0":"2026-05-31T22:29:38.533Z","1.3.1":"2026-05-31T22:32:59.288Z"},"bugs":{"url":"https://github.com/childsr/event_stream/issues"},"author":{"name":"Ryan Childs"},"license":"MIT","homepage":"https://github.com/childsr/event_stream#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/childsr/event_stream.git"},"description":"![npm version](https://img.shields.io/npm/v/@bananaseed/event_stream) ![license](https://img.shields.io/npm/l/@bananaseed/event_stream) ![minzipped size](https://img.shields.io/bundlephobia/minzip/@bananaseed/event_stream)","maintainers":[{"name":"bananaseed","email":"bananaseedgames@gmail.com"}],"readme":"# @bananaseed/event_stream\n\n![npm version](https://img.shields.io/npm/v/@bananaseed/event_stream)\n![license](https://img.shields.io/npm/l/@bananaseed/event_stream)\n![minzipped size](https://img.shields.io/bundlephobia/minzip/@bananaseed/event_stream)\n\n**@bananaseed/event_stream** is a lightweight, type-safe way to treat an event source (e.g. a DOM EventTarget, Node EventEmitter, etc) as a stream of values, applying functional operators like `map`, `filter`, and `reduce`.\n\nAn `EventStream` object itself is just a wrapper around a function that accepts a listener. Nothing actually happens until you call `EventStream.listen()`. It is just a description of what to do when a listener is given to it. The `EventStream` object is never mutated as each method returns a new `EventStream` object.\n\n## Examples\n\n**Basic Example**\n\n```typescript\n// Create an EventStream that emits a random number every second\nconst stream = new EventStream<number>(listener => {\n  const id = setInterval(() => listener(Math.random()), 1000)\n  return { cancel() { clearInterval(id) } }\n})\n// Listen for events, logging each one to the console\nconst controller = stream.listen(console.log)\n// After 5 seconds, stop listening for events\nsetTimeout(() => controller.cancel(), 5000)\n```\n\n**From DOM Events**\n\n```typescript\n// Create an EventStream from click events on a button\nconst button = document.querySelector('button')!\nconst clickStream = EventStream.fromEventTarget(button, 'click')\n// Convert stream of click events into stream of coordinates\nconst clickCoords: EventStream<{ x: number, y: number }> = clickStream.map(\n  event => ({ x: event.clientX, y: event.clientY })\n)\n// Filter clicks to only those within a 10x10 box at (10,10) and log them\nclickCoords\n  .filter(({x,y}) => x > 10 && x < 20 && y > 10 && y < 20)\n  .listen(coords => {\n    console.log(`Clicked within the box: (${coords.x}, ${coords.y})`)\n  })\n```\n\n```typescript\n// Create an EventStream from 'keydown' events on the document\nconst keydownStream = EventStream.fromEventTarget(document, 'keydown')\n// Convert stream of keydown events into stream of key codes\nconst keyCodes: EventStream<number> = keydownStream.map(event => event.keyCode)\n// Filter key codes to only those for the Enter key (key code 13) and log them\nkeyCodes\n  .filter(code => code === 13)\n  .listen(code => {\n    console.log(`Pressed Enter key: ${code}`)\n  })\n```\n\n**`take`, `drop`, and `slice`**\n\n```typescript\n// Create an EventStream that emits a number every 500ms\n// (`fromInterval` emits 0 first and increments by 1 on each successive event)\nconst stream = EventStream.fromInterval(500) // 0, 1, 2, ...\n\n// Take only the first 5 events and ignore the rest\nconst take5 = stream.take(5)\ntake5.listen(console.log) // logs, '0', '1', '2', '3', and '4' then stops\n\n// Ignore the first 5 numbers\nconst drop5 = stream.drop(5)\ndrop5.listen(console.log) // after 2.5 seconds (5 x 500ms) starts logging '5', '6', '7', ...\n\n// Take the first 7 events and drop the first 3\nconst slice3to7 = stream.slice(3, 7)\n// equivalent to...\nconst slice3to7 = stream.take(7).drop(3)\nslice3to7.listen(console.log) // logs, '3', '4', '5', and '6', then stops\n\n```\n\n**Merging Streams**\n\n```typescript\nconst stream1 = EventStream.fromInterval(300).map(x => x+1).map(x => `Stream 1: ${x*3}`)\nconst stream2 = EventStream.fromInterval(500).map(x => x+1).map(x => `Stream 2: ${x*5}`)\nconst mergedStream = EventStream.merge(stream1, stream2)\nmergedStream.listen(console.log)\n// Output:\n// \"Stream 1: 3\"\n// \"Stream 2: 5\"\n// \"Stream 1: 6\"\n// \"Stream 1: 9\"\n// \"Stream 2: 10\"\n// \"Stream 1: 12\"\n// ...etc.\n```","readmeFilename":"README.md"}