{"id":16350451,"url":"https://github.com/zspecza/pipep","last_synced_at":"2026-03-05T22:31:25.841Z","repository":{"id":57157523,"uuid":"61842709","full_name":"zspecza/pipep","owner":"zspecza","description":":saxophone: Functional, composable, immutable \u0026 curried promise sequences with abstract resolution.","archived":false,"fork":false,"pushed_at":"2020-06-01T01:14:31.000Z","size":172,"stargazers_count":111,"open_issues_count":10,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-09-21T20:45:18.816Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/zspecza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-23T23:12:22.000Z","updated_at":"2024-05-10T01:21:54.000Z","dependencies_parsed_at":"2022-09-03T18:51:43.599Z","dependency_job_id":null,"html_url":"https://github.com/zspecza/pipep","commit_stats":null,"previous_names":["declandewet/pipep"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/zspecza/pipep","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspecza%2Fpipep","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspecza%2Fpipep/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspecza%2Fpipep/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspecza%2Fpipep/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zspecza","download_url":"https://codeload.github.com/zspecza/pipep/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspecza%2Fpipep/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30152844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T21:15:50.531Z","status":"ssl_error","status_checked_at":"2026-03-05T21:15:11.173Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2024-10-11T01:05:01.297Z","updated_at":"2026-03-05T22:31:25.808Z","avatar_url":"https://github.com/zspecza.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![build status](https://img.shields.io/travis/declandewet/pipep.svg?style=flat-square)](https://travis-ci.org/declandewet/pipep) [![codecov.io](https://img.shields.io/codecov/c/gh/declandewet/pipep.svg?style=flat-square)](https://codecov.io/gh/declandewet/pipep?branch=master) [![dependency status](https://img.shields.io/david/declandewet/pipep.svg?style=flat-square)](https://david-dm.org/declandewet/pipep) [![dev dependency status](https://img.shields.io/david/dev/declandewet/pipep.svg?style=flat-square)](https://david-dm.org/declandewet/pipep#info=devDependencies)\n\n[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)\n\n# pipeP\n\nFunctional, composable, immutable and curried promise sequences that automatically handle Promise resolution. 0.8kb Minified \u0026 GZIP'd. Inspired by the function of the same name in [Ramda](http://ramdajs.com/0.21.0/docs/#pipeP).\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n# Table of Contents\n\n- [Requirements](#requirements)\n- [Installation](#installation)\n  - [Node.js](#nodejs)\n  - [Browser](#browser)\n      - [Development/Uncompressed](#developmentuncompressed)\n      - [Production/Minified](#productionminified)\n- [Why Should You Care?](#why-should-you-care)\n    - [Removes the need to call `.then()` in a promise pipeline](#removes-the-need-to-call-then-in-a-promise-pipeline)\n    - [Automatic value, array and promise coercion](#automatic-value-array-and-promise-coercion)\n    - [Works with varying arguments](#works-with-varying-arguments)\n    - [Immutable data](#immutable-data)\n    - [Automatic currying](#automatic-currying)\n    - [No-Sweat Composition](#no-sweat-composition)\n    - [Handles array arguments](#handles-array-arguments)\n    - [Bonus Snippet: Recursion \u0026 Sharing Context](#bonus-snippet-recursion-\u0026-sharing-context)\n- [API](#api)\n  - [pipeP(…(Array\u003cFunction\u003e|Function)) =\u003e Function](#pipep%E2%80%A6arrayfunctionfunction--function)\n- [How to Contribute](#how-to-contribute)\n- [License](#license)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Requirements\n\n**pipeP** has no dependencies and is exported as a UMD module, so it should be consumable anywhere. However, it does rely on access to ES2015 native `Promise` and `Object.assign`. Since these are standard, your environment needs to support them. By default, **pipeP** does not ship with any fallbacks in order to keep the code size manageable. If you're already using an ES2015 environment, you have nothing to worry about. Otherwise, see [CoreJS](https://github.com/zloirock/core-js).\n\n## Limitations\n\n**IE8**: This is really only applicable if you use the currying features. **pipeP** makes use of `Object.defineProperty` in order to make functions returned by a **pipeP** sequence report the correct arity, so that they can then be used as the first handler in a new **pipeP** sequence. There are known limitations in Internet Explorer 8 that prevent this from working correctly. A possible workaround is to not use a **pipeP** returned function as the first handler in a new **pipeP** sequence. Instead, make it unary, use it as the second handler and provide your own initial handler that translates arguments accordingly.\n\n## Installation\n\n### Node.js\n\n```sh\n$ npm i pipep -S\n```\n\nThen your code:\n\n```js\nvar pipeP = require('pipep')\n// if using ES2015: `import pipeP from 'pipep'`\n```\n\n### Browser\n\nYou can grab the latest release from npm CDN ([See this for instructions on how to specify a specific version](https://unpkg.com)):\n\n##### Development/Uncompressed\n\n[pipep.js](https://unpkg.com/pipep)\n\n```html\n\u003cscript src=\"//unpkg.com/pipep\"\u003e\u003c/script\u003e\n```\n\n##### Production/Minified\n\n[pipep.min.js](https://unpkg.com/pipep/pipep.min.js)\n\n```html\n\u003cscript src=\"//unpkg.com/pipep/pipep.min.js\"\u003e\u003c/script\u003e\n```\n\n\n\n## Why Should You Care?\n\n**pipeP** can do some pretty cool things:\n\n#### Removes the need to call `.then()` in a promise pipeline\n\nThis abstraction gives you the ability to process variable-length promise chains and also enables chains to be point-free:\n\n```js\n// pipeline - use of composed \"fetch\" is point-free\nconst getJSON = pipeP(fetch, handleError, grabJSON)\n\ngetJSON('http://randomuser.me/api')\n  .then(console.log.bind(console))\n  .catch((err) =\u003e console.error(err))\n\nfunction handleError (response) {\n  if (!response.ok) {\n    throw new Error(response.status + ' ' + response.statusText)\n  }\n  return response\n}\n\nfunction grabJSON (response) {\n  return response.json()\n}\n```\n\n#### Automatic value, array and promise coercion\n\n**pipeP** abstracts all type resolution for you:\n\n```js\nconst process = pipeP((x) =\u003e [x, 5], ([x, y]) =\u003e [x, y, Promise.resolve(15)])\nprocess(Promise.resolve(10)).then(console.log.bind(console)) // logs '[10, 5, 15]'\n```\n\n#### Works with varying arguments\n\nAll handlers passed to **pipeP** operate on and receive a single value (this is how promises work), but you can reduce a single value from many arguments in the first handler:\n\n```js\nconst addAndSquare = pipeP(\n  (a, b) =\u003e a + b,\n  (n) =\u003e n * n\n)\naddAndSquare(2, 3).then(console.log.bind(console)) // logs '25'\n```\n\n#### Immutable data\n\n**pipeP** makes a best effort to not mutate your data:\n\n```js\nconst obj = { foo: 'bar' }\nconst process = pipeP(\n  (x) =\u003e {\n    x.foo = x.foo.toUpperCase()\n    x.bar = 'baz'\n  }\n)\nprocess(obj).then((x) =\u003e {\n  console.log(x) // logs '{ foo: 'BAR', bar: 'baz' }'\n  console.log(obj) // logs '{ foo: 'bar' }'\n})\n```\n\n#### Automatic currying\n\n**pipeP** automatically curries the returned function to the arity of the first handler:\n\n```js\nconst add = pipeP((a, b) =\u003e a + b)\nconst increment = add(1)\nincrement(5).then(console.log.bind(console)) // logs '6'\n```\n\n#### No-Sweat Composition\n\nFunctions returned from **pipeP** are just functions, so they can also be used as handlers in a **pipeP** sequence. They also support currying:\n\n```js\nconst add = pipeP((a, b) =\u003e a + b)\nconst square = pipeP((n) =\u003e n * n)\nconst addAndSquare = pipeP(add, square)\naddAndSquare(5, 2).then(console.log.bind(console)) // logs '49'\naddAndSquare(1)(3).then(console.log.bind(console)) // logs '16'\n```\n\n#### Handles array arguments\n\nIf you already have an array of functions, **pipeP** will accept it as input anywhere in the argument list, and will still support currying:\n\n```js\nconst mathbomb = pipeP(\n  [(a, b) =\u003e a + b, (n) =\u003e n * n],\n  (n) =\u003e n / 2,\n  [(n) =\u003e n - 1, (n) =\u003e n + 5]\n)\nmathbomb(1, 2).then(console.log.bind(console)) // logs '8.5'\nmathbomb(2)(3).then(console.log.bind(console)) // logs '16.5\n```\n\n#### Bonus Snippet: Recursion \u0026 Sharing Context\n\nYou can share context between **pipeP** handlers by passing an array of arguments to the next handler. Behind the scenes, **pipeP** will use `Promise.all` to resolve the arguments. Here is a recursive call to the Github API that serves as a good example:\n\n```js\nconst GET = pipeP(fetch, (res) =\u003e {\n  if (!res.ok) {\n    throw new Error(`${response.status} ${response.statusText}`)\n  }\n  return res\n})\n\nconst constructCommitAPICall = (repo, page) =\u003e {\n  return `https://api.github.com/repos/${repo}/commits?page=${page}\u0026per_page=100`\n}\n\nconst getCommits = pipeP(\n  // if only received 1 arg, set some defaults\n  (...args) =\u003e args.length \u003e 1 ? args : [...args, [], 1],\n  // get page `page` of the commits for the passed `repo` \u0026 martial down arguments\n  ([repo, _, page]) =\u003e [...arguments, GET(constructCommitAPICall(repo, page))],\n  // martial down the commits\n  ([repo, pages, page, commits]) =\u003e {\n    // append the commits for page `page` in the `pages` array\n    pages.push(commits.json())\n    // inspect response headers for current page\n    for (const curr of Array.values(commits.headers.get('Link').split(', '))) {\n      // if there is a link for the next page, grab the commits from it\n      if (/rel=\"next\"/.test(curr)) {\n        return getCommits(repo, pages, page + 1)\n      }\n    }\n    return pages\n  },\n  // flatten the pages into a single list of commits\n  (pages) =\u003e pages.reduce((a, b) =\u003e a.concat(b), [])\n)\n```\n\n## API\n\n### pipeP(…(Array\u003cFunction\u003e|Function)) =\u003e Function\n\nAccepts any number of arguments. Each argument can either be a unary function or an array containing unary functions.\n\n\"Unary\" means that they can only accept one argument and return one argument.\n\nThe first function passed to **pipeP** (whether in an array or not) can accept as many arguments as you want it to, as long as it returns a single value.\n\nThese functions may accept and/or return values or promises for values. Conversion between arrays, promises and values is abstracted for you.\n\nReturns a function that is curried to the same number of arguments as the first function passed to **pipeP**. When this function receives all expected arguments, it will return a promise for the single computed value of its input after being _piped_ through each function passed to **pipeP**.\n\n## How to Contribute\n\nPlease read the [Contribution Guidelines](CONTRIBUTING.md).\n\n## License\n\nMIT. See [LICENSE](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzspecza%2Fpipep","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzspecza%2Fpipep","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzspecza%2Fpipep/lists"}