{"id":10607,"library":"callbag-pipe","title":"Callbag Pipe Utility","description":"callbag-pipe is a lightweight utility function designed to chain callbags together in a functional pipeline, conceptually similar to `Ramda.pipe` or `lodash.flow`. It serves as a foundational component within the Callbag ecosystem, facilitating the clear and concise composition of Callbag sources and operators. The current stable version is 1.2.0, and as a small, focused utility, it typically sees a low-frequency release cadence, with updates primarily for compatibility or minor enhancements rather than new features. Its key differentiator is its seamless integration with the Callbag specification, making it a natural choice for creating and consuming Callbag streams, while offering a familiar functional composition pattern. It provides TypeScript types for improved developer experience and type safety.","status":"active","version":"1.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/staltz/callbag-pipe","tags":["javascript","callbag","typescript"],"install":[{"cmd":"npm install callbag-pipe","lang":"bash","label":"npm"},{"cmd":"yarn add callbag-pipe","lang":"bash","label":"yarn"},{"cmd":"pnpm add callbag-pipe","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The `pipe` function is typically exported as a named export in ESM environments.","wrong":"import pipe from 'callbag-pipe';","symbol":"pipe","correct":"import { pipe } from 'callbag-pipe';"},{"note":"For CommonJS environments, `pipe` is the default export of the module.","symbol":"pipe (CommonJS)","correct":"const pipe = require('callbag-pipe');"},{"note":"When only importing types, use the `type` keyword for tree-shaking and clarity, especially when not directly using the runtime value in a TypeScript project.","symbol":"pipe (Type Definition)","correct":"import type { pipe } from 'callbag-pipe';"}],"quickstart":{"code":"import { pipe } from 'callbag-pipe';\nimport interval from 'callbag-interval';\nimport forEach from 'callbag-for-each';\nimport combine from 'callbag-combine';\nimport take from 'callbag-take';\nimport map from 'callbag-map';\n\n// Create a pipeline that combines two intervals, maps their values, takes the first 10, and logs them.\npipe(\n  combine(interval(100), interval(350)),\n  map(([x, y]: [number, number]) => `X${x},Y${y}`),\n  take(10),\n  forEach((x: string) => console.log(x))\n);\n\n// Expected output:\n// X2,Y0\n// X3,Y0\n// X4,Y0\n// X5,Y0\n// X6,Y0\n// X6,Y1\n// X7,Y1\n// X8,Y1\n// X9,Y1\n// X9,Y2","lang":"typescript","description":"This example demonstrates creating a complete Callbag stream from source to sink using `pipe`, combining two interval streams, mapping their values, taking a limited number, and logging the output."},"warnings":[{"fix":"Wrap the inner `pipe` in a function that accepts the source. For example, `s => pipe(s, map(f), take(amount))` or `s => pipe(s, ...innerOperators)`.","message":"When nesting `pipe` calls to create new operators or inline pipelines, the inner `pipe` must explicitly receive its source argument as a function. Direct nesting like `pipe(source, pipe(op1, op2))` will not work as expected.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Install necessary Callbag operators via `npm install callbag-map callbag-take` etc., and import them appropriately (`import map from 'callbag-map';`).","message":"Although `callbag-pipe` itself has no runtime dependencies outside of the Callbag specification, its utility is realized by composing it with other Callbag operators (e.g., `callbag-map`, `callbag-take`). Ensure these operators are installed and imported correctly when building pipelines.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure you are using the correct import syntax for your module system: `import { pipe } from 'callbag-pipe';` for ESM or `const pipe = require('callbag-pipe');` for CommonJS. Check your `package.json` for proper module configuration if using bundlers.","cause":"The `pipe` function was imported incorrectly, or the module was not properly resolved in the environment.","error":"TypeError: pipe is not a function"},{"fix":"Review the type signatures of the Callbag operators being chained. Ensure that the output type of one operator matches the expected input type of the next. Use explicit type annotations in TypeScript if necessary to debug type flow, e.g., `map(([x, y]: [number, number]) => ...)`.","cause":"Type mismatch when chaining Callbag operators within `pipe`, often due to an operator expecting a different type of source or producing an unexpected output type.","error":"Argument of type '...' is not assignable to parameter of type 'Callbag<any, any>'."}],"ecosystem":"npm"}