{"id":11120,"library":"ix","title":"The Interactive Extensions for JavaScript (IxJS)","description":"IxJS, currently stable at version 7.0.0, is a JavaScript library providing the \"Interactive Extensions\" for composing synchronous and asynchronous pull-based collections. It extends the familiar Array#extras style (like map, filter, reduce) to native JavaScript `Iterable` and `AsyncIterable` objects, as well as generators and async generators. Unlike push-based reactive libraries such as RxJS, IxJS focuses on consumer-driven data flow, making it particularly well-suited for I/O operations where data is pulled when ready. The library offers distinct modules for synchronous (`ix/iterable`) and asynchronous (`ix/asynciterable`) operations, supporting both pipeable operators and a prototype-extension approach for bundling flexibility. It ships with full TypeScript type definitions and maintains a steady release cadence, typically with minor versions for features and bug fixes, with major versions addressing internal changes or deeper refactorings.","status":"active","version":"7.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/ReactiveX/IxJS","tags":["javascript","Iterator","Iterable","Promise","Async","AsyncIterable","AsyncIterator","typescript"],"install":[{"cmd":"npm install ix","lang":"bash","label":"npm"},{"cmd":"yarn add ix","lang":"bash","label":"yarn"},{"cmd":"pnpm add ix","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Use the specific `ix/iterable` or `ix/asynciterable` path for the `from` creation function, not the root package.","wrong":"import { from } from 'ix';","symbol":"from","correct":"import { from } from 'ix/iterable';"},{"note":"Pipeable operators are imported from `ix/iterable/operators` for synchronous operations or `ix/asynciterable/operators` for asynchronous operations. Do not import directly from the root `ix` package.","wrong":"import { filter, map } from 'ix';","symbol":"pipeable operators","correct":"import { filter, map } from 'ix/iterable/operators';"},{"note":"The `IterableX` and `AsyncIterableX` classes are the core types for working with these extensions. Use `IterableX` for synchronous and `AsyncIterableX` for asynchronous.","wrong":"const { IterableX } = require('ix/iterable'); // CommonJS is supported, but ESM is preferred in modern applications.","symbol":"IterableX / AsyncIterableX","correct":"import { IterableX } from 'ix/iterable';\nimport { AsyncIterableX } from 'ix/asynciterable';"},{"note":"To extend `IterableX` or `AsyncIterableX` prototypes, use side-effect imports from `ix/add/...`. These are global modifications and should be used with caution, typically for bundling scenarios where tree-shaking isn't as effective.","wrong":"import { map } from 'ix/add/iterable-operators/map';","symbol":"Prototype extensions","correct":"import 'ix/add/iterable/of';\nimport 'ix/add/iterable-operators/map';"}],"quickstart":{"code":"import { from } from 'ix/iterable';\nimport { filter, map } from 'ix/iterable/operators';\n\n// A synchronous generator function\nfunction* numberGenerator() {\n  yield 1;\n  yield 2;\n  yield 3;\n  yield 4;\n  yield 5;\n  yield 6;\n}\n\n// Create an Iterable from the generator and apply pipeable operators\nconst results = from(numberGenerator()).pipe(\n  filter(x => x % 2 === 0), // Keep only even numbers\n  map(x => x * 10)         // Multiply by 10\n);\n\nconsole.log('Synchronous Iterable results:');\nfor (const item of results) {\n  console.log(`Next: ${item}`);\n}\n\n// To demonstrate AsyncIterable, imagine an async data source\n// import { from as asyncFrom } from 'ix/asynciterable';\n// import { filter as asyncFilter, map as asyncMap } from 'ix/asynciterable/operators';\n\n// async function* asyncNumberGenerator() {\n//   for (let i = 1; i <= 6; i++) {\n//     await new Promise(resolve => setTimeout(resolve, 50));\n//     yield i;\n//   }\n// }\n\n// async function runAsyncExample() {\n//   const asyncResults = asyncFrom(asyncNumberGenerator()).pipe(\n//     asyncFilter(x => x % 2 !== 0), // Keep only odd numbers\n//     asyncMap(x => x + 100)       // Add 100\n//   );\n\n//   console.log('\\nAsynchronous Iterable results:');\n//   for await (const item of asyncResults) {\n//     console.log(`Next Async: ${item}`);\n//   }\n// }\n\n// runAsyncExample();","lang":"typescript","description":"Demonstrates creating a synchronous `Iterable` from a generator function and transforming it using pipeable `filter` and `map` operators, then iterating through the results."},"warnings":[{"fix":"Always ensure you are importing from either `ix/iterable` for sync operations or `ix/asynciterable` for async operations, and their respective `operators` submodules.","message":"IxJS maintains separate modules for synchronous (`ix/iterable`) and asynchronous (`ix/asynciterable`) operations. Mixing operators or creators from these distinct modules on the wrong type of iterable will lead to runtime errors or incorrect behavior.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Thoroughly test your application when upgrading major versions. Refer to the GitHub release notes and commit history for subtle behavioral changes or type definition improvements.","message":"Major version updates (e.g., v5.0.0, v6.0.0, v7.0.0) in IxJS often contain internal refactorings and bug fixes. While explicit breaking API changes might not always be prominently documented, minor behavioral changes or stricter type checks can occur, potentially affecting edge cases.","severity":"gotcha","affected_versions":">=5.0.0"},{"fix":"Prefer using pipeable operators by importing them directly (e.g., `import { map } from 'ix/iterable/operators';`) and composing them with the `.pipe()` method on your iterable instances. This enables better tree-shaking and avoids global prototype modifications.","message":"The pattern of directly importing side-effect modules (e.g., `import 'ix/add/iterable-operators/map';`) to extend prototypes is less common in modern applications favoring tree-shaking. While supported, it can lead to larger bundle sizes if not all added operators are used.","severity":"deprecated","affected_versions":">=4.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure the operator is imported from `ix/iterable/operators` (or `ix/asynciterable/operators`) and used with the `.pipe()` method, or that the corresponding `ix/add/...` module has been imported for prototype extension.","cause":"Attempting to use an operator (e.g., `map`, `filter`) directly on an `IterableX` or `AsyncIterableX` instance without either importing it as a pipeable operator or adding it via the prototype extension.","error":"TypeError: (some operator) is not a function"},{"fix":"Verify that your data source is truly asynchronous (e.g., an `AsyncGenerator`, `Promise` of an `Iterable`) and that you are consistently using imports from `ix/asynciterable` and `ix/asynciterable/operators`.","cause":"Attempting to use an asynchronous operator or an `AsyncIterableX` method on a synchronous `Iterable` or a non-async data source.","error":"TypeError: Cannot read property 'Symbol.asyncIterator' of undefined"},{"fix":"Always use specific import paths for creators and operators, such as `import { from } from 'ix/iterable';` or `import { map } from 'ix/asynciterable/operators';`.","cause":"Incorrect import path for creation functions or operators; these are not directly exposed from the root `ix` package.","error":"SyntaxError: Named export 'from' not found. The requested module 'ix' does not provide an export named 'from'."}],"ecosystem":"npm"}