{"id":16414079,"url":"https://github.com/trvswgnr/sloth-pipe","last_synced_at":"2025-05-09T00:04:37.545Z","repository":{"id":218981589,"uuid":"747589461","full_name":"trvswgnr/sloth-pipe","owner":"trvswgnr","description":"A lazy evaluated, chainable, and reusable pipe for data transformation and processing.","archived":false,"fork":false,"pushed_at":"2024-07-23T17:20:58.000Z","size":865,"stargazers_count":182,"open_issues_count":8,"forks_count":9,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-09T00:04:27.152Z","etag":null,"topics":["fast","fp","functional","javascript","lazy","library","pipe","processing","programming","typescript"],"latest_commit_sha":null,"homepage":"https://sloth-pipe.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trvswgnr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":["trvswgnr"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2024-01-24T08:40:03.000Z","updated_at":"2025-04-17T17:13:59.000Z","dependencies_parsed_at":"2024-10-25T18:03:27.565Z","dependency_job_id":"6bf399e6-3ba0-4f57-8b1b-d7b9dbdcd156","html_url":"https://github.com/trvswgnr/sloth-pipe","commit_stats":null,"previous_names":["trvswgnr/sloth-pipe"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trvswgnr%2Fsloth-pipe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trvswgnr%2Fsloth-pipe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trvswgnr%2Fsloth-pipe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trvswgnr%2Fsloth-pipe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trvswgnr","download_url":"https://codeload.github.com/trvswgnr/sloth-pipe/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253166514,"owners_count":21864475,"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":["fast","fp","functional","javascript","lazy","library","pipe","processing","programming","typescript"],"created_at":"2024-10-11T06:53:12.652Z","updated_at":"2025-05-09T00:04:37.511Z","avatar_url":"https://github.com/trvswgnr.png","language":"TypeScript","funding_links":["https://github.com/sponsors/trvswgnr"],"categories":[],"sub_categories":[],"readme":"![sloth-pipe](/docs/src/assets/readme-banner.png)\n\n# Sloth Pipe\n\n\u003c!-- start badges --\u003e\n\n[![github latest release](https://badgen.net/github/tag/trvswgnr/sloth-pipe?label=latest\u0026cache=600)](https://github.com/trvswgnr/sloth-pipe/releases/latest)\n[![npm version](https://badgen.net/npm/v/sloth-pipe?cache=600)](https://www.npmjs.com/package/sloth-pipe)\n![npm weekly downloads](https://img.shields.io/npm/dw/sloth-pipe)\n![dependencies](https://img.shields.io/badge/dependencies-0-orange)\n[![license](https://img.shields.io/github/license/trvswgnr/sloth-pipe)](LICENSE)\n[![open issues](https://badgen.net/github/open-issues/trvswgnr/sloth-pipe?label=issues)](https://github.com/trvswgnr/sloth-pipe/issues)\n[![minzipped size](https://img.shields.io/bundlephobia/minzip/sloth-pipe)](https://bundlephobia.com/result?p=sloth-pipe)\n![follow on xitter](https://img.shields.io/twitter/follow/techsavvytravvy?style=social)\n\n\u003c!-- end badges --\u003e\n\nSloth Pipe is a tiny library for TypeScript and JavaScript that lets you create lazy, chainable, and\nreusable pipes for data transformation and processing. Borrowing from functional programming\nparadigms, it offers a convenient and powerful way to compose functions and manage data flow in an\napplication, with an emphasis on lazy evaluation and efficient execution.\n\n## Why Sloth Pipe?\n\nDevelopers want pipes. They've been one of the\n[most requested features](https://2020.stateofjs.com/en-US/opinions/#missing_from_js) in JavaScript\n[for years](https://2022.stateofjs.com/en-US/opinions/#top_currently_missing_from_js), and there's\neven a [Stage 2 proposal](https://github.com/tc39/proposal-pipeline-operator) for adding them to the\nlanguage. Sloth Pipe isn't a direct replacement for the proposed pipeline operator, but it does\noffer a similar experience and many of the\n[same benefits](https://github.com/tc39/proposal-pipeline-operator#why-a-pipe-operator).\n\n## Features\n\n-   **Lazy Evaluation**: Computations are only performed when necessary, optimizing performance and\n    resource utilization.\n-   **Chainable API**: Enables the creation of fluent and readable code by chaining multiple\n    operations.\n-   **Error Handling**: Built-in support for error handling within the pipe.\n-   **Async/Await Compatibility**: Seamlessly integrate asynchronous functions into your pipes.\n-   **Tap Operations**: Allows side-effects without altering the pipe's main data flow.\n-   **Reusable pipes**: Easily reuse pipes, even after execution.\n-   **Extensible**: Easily extendable with custom functions and operations.\n-   **Type-Safe**: Written in TypeScript, with full support for type inference and type safety.\n-   **Lightweight**: Small and lightweight, with no external dependencies.\n-   **Well-Tested**: Thoroughly tested with 100% code coverage.\n\n## Installation\n\nTo install Sloth Pipe, use the following command:\n\n```bash\nbun i sloth-pipe\n```\n\nor\n\n```bash\nnpm install sloth-pipe\n```\n\n## Usage\n\nHere's a simple example of how to use Sloth Pipe:\n\n```typescript\nimport { Pipe } from \"sloth-pipe\";\n\nconst result = Pipe(5)\n    .to((x) =\u003e x * 2)\n    .to((x) =\u003e x + 3)\n    .exec();\n\nconsole.log(result); // Outputs: 13\n```\n\n### Async Operations\n\nSloth Pipe seamlessly integrates with asynchronous operations:\n\n```typescript\nconst add = async (x: Promise\u003cnumber\u003e, y: number) =\u003e {\n    const xVal = await x;\n    return xVal + y;\n};\nconst asyncResult = await Pipe(5)\n    .to(async (x) =\u003e x * 2)\n    .to(add, 3) // pass additional arguments to any function\n    .exec();\n\nconsole.log(asyncResult); // Outputs: 13\n```\n\n### Error Handling\n\nHandle errors gracefully within the pipe:\n\n```typescript\nconst safeResult = Pipe(5)\n    .to((x) =\u003e {\n        if (x \u003e 0) throw new Error(\"Example error\");\n        return x;\n    })\n    .catch((err) =\u003e 0)\n    .exec();\n\nconsole.log(safeResult); // Outputs: 0\n```\n\n## API Reference\n\nThe API consists of a few key methods: `to`, `tap`, `exec`, and `catch`. For a detailed reference,\nplease refer to the [API documentation](https://sloth-pipe.vercel.app/).\n\n## Contributing\n\nAny and all contributions are welcome! Open an issue or submit a pull request to contribute.\n\nThis project uses [Bun](https://bun.sh) for development. To get started, clone the repository and\nrun `bun install` to install dependencies. Then, run `bun test` to run the test suite.\n\nTo build the project, run `bun build`. The output will be in the `dist` directory.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrvswgnr%2Fsloth-pipe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrvswgnr%2Fsloth-pipe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrvswgnr%2Fsloth-pipe/lists"}