{"id":25411540,"url":"https://github.com/dynamik-dev/zenpipe","last_synced_at":"2025-04-14T08:28:43.759Z","repository":{"id":248739202,"uuid":"829526100","full_name":"dynamik-dev/zenpipe","owner":"dynamik-dev","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-11T16:32:02.000Z","size":105,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-11T17:35:51.728Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dynamik-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-16T15:54:46.000Z","updated_at":"2025-02-11T16:31:37.000Z","dependencies_parsed_at":"2024-07-16T21:39:39.081Z","dependency_job_id":"5777f390-44e8-45fb-ac35-d0251d9a7b01","html_url":"https://github.com/dynamik-dev/zenpipe","commit_stats":null,"previous_names":["christopherarter/zenpipe","dynamik-dev/zenpipe"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamik-dev%2Fzenpipe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamik-dev%2Fzenpipe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamik-dev%2Fzenpipe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamik-dev%2Fzenpipe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dynamik-dev","download_url":"https://codeload.github.com/dynamik-dev/zenpipe/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248845297,"owners_count":21170735,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-16T10:18:52.199Z","updated_at":"2025-04-14T08:28:43.734Z","avatar_url":"https://github.com/dynamik-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ZenPipe\n\nZenPipe is a versatile utility function for composing and executing a series of functions in a pipeline. It allows for both synchronous and asynchronous function composition, with flexible execution options.\n\n## Features\n\n- Compose multiple functions into a single pipeline\n- Support for both synchronous and asynchronous functions\n- Option to run all functions asynchronously\n- Automatic handling of mixed synchronous and asynchronous functions\n- TypeScript support with generics for input and output types\n\n## Usage\n\n```typescript\nimport { zenpipe } from './zenpipe';\n\n// Example functions\nconst double = (x: number) =\u003e x * 2;\nconst addOne = (x: number) =\u003e x + 1;\nconst asyncSquare = async (x: number) =\u003e {\n  await new Promise(resolve =\u003e setTimeout(resolve, 100));\n  return x * x;\n};\n\n// Create a pipeline\nconst pipeline = zenpipe([double, addOne, asyncSquare]);\n\n// Use the pipeline\npipeline(5).then(result =\u003e console.log(result)); // Output: 121\n```\n\n## API\n\n### `zenpipe\u003cI, O\u003e(fns: AnyFunc[], options?: ZenPipeOptions): (input: I) =\u003e Promise\u003cO\u003e`\n\nCreates a pipeline of functions that can be executed with a single input.\n\n#### Parameters\n\n- `fns`: An array of functions to be composed into a pipeline.\n- `options` (optional): An object with the following properties:\n  - `runAsync` (optional): If set to `true`, all functions in the pipeline will be executed asynchronously. Default is `false`.\n\n#### Returns\n\nA function that takes an input of type `I` and returns a Promise resolving to type `O`.\n\n## Behavior\n\n1. By default, ZenPipe executes synchronous functions immediately and groups asynchronous functions to be executed at the end of the pipeline.\n2. When `runAsync` is set to `true`, all functions are treated as asynchronous and executed in order.\n3. The pipeline always returns a Promise, regardless of whether the functions are synchronous or asynchronous.\n\n## Types\n\n```typescript\ntype AnyFunc = (...args: any[]) =\u003e any;\n\ninterface ZenPipeOptions {\n  runAsync?: boolean;\n}\n```\n\n## Examples\n\n### Mixed Synchronous and Asynchronous Functions\n\n```typescript\nconst pipeline = zenpipe([\n  (x: number) =\u003e x + 1,\n  async (x: number) =\u003e x * 2,\n  (x: number) =\u003e x.toString()\n]);\n\npipeline(5).then(console.log); // Output: \"12\"\n```\n\n### Forcing Asynchronous Execution\n\n```typescript\nconst pipeline = zenpipe([\n  (x: number) =\u003e x + 1,\n  (x: number) =\u003e x * 2,\n  (x: number) =\u003e x.toString()\n], { runAsync: true });\n\npipeline(5).then(console.log); // Output: \"12\"\n```\n\n## Notes\n\n- The pipeline preserves the order of function execution as specified in the input array.\n- When using TypeScript, you can specify input and output types for better type inference: `zenpipe\u003cnumber, string\u003e([...])`.\n- Error handling should be implemented by the user, either within the pipeline functions or when consuming the result of the pipeline.\n\n## Contributing\n\nFeel free to submit issues or pull requests if you have suggestions for improvements or find any bugs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdynamik-dev%2Fzenpipe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdynamik-dev%2Fzenpipe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdynamik-dev%2Fzenpipe/lists"}