{"id":20565727,"url":"https://github.com/phenax/pipey","last_synced_at":"2025-04-14T15:35:35.369Z","repository":{"id":33172854,"uuid":"154014496","full_name":"phenax/pipey","owner":"phenax","description":"Create pipeline operator ready functions by converting instance methods's to context-free functions","archived":false,"fork":false,"pushed_at":"2022-12-08T19:14:39.000Z","size":511,"stargazers_count":24,"open_issues_count":17,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T04:30:39.588Z","etag":null,"topics":["currying","functional-programming","javascript","pipe-operator","prototype"],"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/phenax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"custom":["https://www.paypal.me/phenax","https://www.buymeacoffee.com/phenax"],"liberapay":"phenax"}},"created_at":"2018-10-21T14:00:59.000Z","updated_at":"2023-06-22T20:18:54.000Z","dependencies_parsed_at":"2023-01-14T23:46:48.587Z","dependency_job_id":null,"html_url":"https://github.com/phenax/pipey","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Fpipey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Fpipey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Fpipey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Fpipey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phenax","download_url":"https://codeload.github.com/phenax/pipey/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248906976,"owners_count":21181253,"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":["currying","functional-programming","javascript","pipe-operator","prototype"],"created_at":"2024-11-16T04:38:50.834Z","updated_at":"2025-04-14T15:35:35.344Z","avatar_url":"https://github.com/phenax.png","language":"JavaScript","funding_links":["https://www.paypal.me/phenax","https://www.buymeacoffee.com/phenax","https://liberapay.com/phenax"],"categories":[],"sub_categories":[],"readme":"\n# Pipey\nUtility functions to convert instance methods's to context-free functions ready for use with [esnext pipeline operator](https://github.com/tc39/proposal-pipeline-operator) and point-free functional programming. Convert any `x.whatever(...args)` to `whatever(...arg)(x)`.\n\n[![CircleCI](https://img.shields.io/circleci/project/github/phenax/pipey/master.svg?style=for-the-badge)](https://circleci.com/gh/phenax/pipey)\n[![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/pipey.svg?style=for-the-badge)](https://www.npmjs.com/package/pipey)\n[![Codecov](https://img.shields.io/codecov/c/github/phenax/pipey.svg?style=for-the-badge)](https://codecov.io/gh/phenax/pipey)\n\n\n[Read the documentation for more information](https://github.com/phenax/pipey/tree/master/docs)\n\n\n### Install it\n```bash\nyarn add pipey\n```\n\n### Import it to your file\n```js\nimport { createPipe, createPipes, fromClassPrototype, compose } from 'pipey';\n// Note: compose is a regular lodash-like compose function\n\nimport _ from 'pipey/proxy'; // For proxy-based api\n```\n\n### fromClassPrototype\n```js\nconst { map, filter } = fromClassPrototype(Array);\n\nconst doubleNumbers = map(x =\u003e x * 2);\nconst doubleOddNumbers = compose(doubleNumbers, filter(x =\u003e x % 2));\n\ndoubleOddNumbers([ 2, 3, 4, 5 ]); // Returns [ 6, 10 ]\n```\n\n### createPipe\n```js\nconst forEach = createPipe('forEach');\nforEach(x =\u003e console.log(x))([ 1, 2, 3, 4 ]); // Logs 1 2 3 4\n```\n\n### createPipes\n```js\nconst { map, filter, split } = createPipes(['map', 'filter', 'split']);\nconst head = ([ first ]) =\u003e first;\nconst compact = filter(Boolean);\n\nconst getFirstNames = names =\u003e\n  names\n    |\u003e compact\n    |\u003e map(split(' '))\n    |\u003e map(head);\n\ngetFirstNames([ '', null, 'Akshay Nair', 'John Doe', 'Bruce Fucking Lee' ]); // Returns ['Akshay', 'John', 'Bruce']\n```\n\n### Proxy based api\nA proxy based alternative api for pipey\n[Read the documentation](https://github.com/phenax/pipey/tree/master/docs/proxy.md)\n\n```js\nimport _ from 'pipey/proxy';\n\nconst getInitials = compose(\n  _.join(''),\n  _.map(_.charAt(0)),\n  _.split(' '),\n  _.$prop('name'), // $prop is a pre-defined plugin\n);\n\ngetInitials({ name: 'Akshay Nair' }) === 'AN';\n```\n\n### Example use cases\n\n* Using with the amazing pipe operator\n```js\nconst { map, filter, reduce } = fromClassPrototype(Array);\n\nconst getInputData = () =\u003e\n  document.querySelectorAll('.js-input')\n    |\u003e map($input =\u003e [ $input.name, $input.value ])\n    |\u003e filter(([_, value]) =\u003e value)\n    |\u003e Object.fromEntries\n    |\u003e Array.from;\n\ngetInputData(); // Returns something like { email: 'han.solo@gmail.com', name: 'Han Solo' }\n```\n\n* Working with collection methods\n```js\n// Two ways to extract methods out (createPipes \u0026 fromClassPrototype)\nconst { map, filter } = fromClassPrototype(Array);\nconst { split } = createPipes(['split']);\n\nconst getFirstNames = compose(\n  map(xs =\u003e xs[0]),\n  map(split(' ')),\n  filter(Boolean),\n);\n\ngetFirstNames([ '', null, 'Akshay Nair', 'John Doe', 'Bruce Fucking Lee' ]); // Returns ['Akshay', 'John', 'Bruce']\n```\n\n\n* Working with dom methods\n```js\nconst { forEach, join } = fromClassPrototype(Array);\nconst { setAttribute } = fromClassPrototype(HTMLInputElement);\nconst inputs = ['.js-input-name', '.js-input-email'];\n\ninputs\n  |\u003e join(', ')\n  |\u003e (selector =\u003e document.querySelectorAll(selector))\n  |\u003e forEach(setAttribute('disabled', 'disabled'));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphenax%2Fpipey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphenax%2Fpipey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphenax%2Fpipey/lists"}