{"id":20354724,"url":"https://github.com/superpaintman/babel-plugin-transform-pipeline","last_synced_at":"2025-04-12T02:36:30.740Z","repository":{"id":79226570,"uuid":"85445252","full_name":"SuperPaintman/babel-plugin-transform-pipeline","owner":"SuperPaintman","description":"Compile pipeline operator to ES5","archived":false,"fork":false,"pushed_at":"2017-09-08T17:48:08.000Z","size":30,"stargazers_count":59,"open_issues_count":6,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-12T02:36:21.193Z","etag":null,"topics":["babel","babel-plugin","ecmascript","ecmascript-proposal","ecmascript-syntax"],"latest_commit_sha":null,"homepage":null,"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/SuperPaintman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2017-03-19T02:18:45.000Z","updated_at":"2023-04-26T00:41:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"f3b1fbab-02f5-4c61-bcfa-480f6f89a6c1","html_url":"https://github.com/SuperPaintman/babel-plugin-transform-pipeline","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"f05f9cbb07a31f71e2ce0ba67d9c0324fbe0ae73"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SuperPaintman%2Fbabel-plugin-transform-pipeline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SuperPaintman%2Fbabel-plugin-transform-pipeline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SuperPaintman%2Fbabel-plugin-transform-pipeline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SuperPaintman%2Fbabel-plugin-transform-pipeline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SuperPaintman","download_url":"https://codeload.github.com/SuperPaintman/babel-plugin-transform-pipeline/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248506989,"owners_count":21115519,"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":["babel","babel-plugin","ecmascript","ecmascript-proposal","ecmascript-syntax"],"created_at":"2024-11-14T23:09:29.252Z","updated_at":"2025-04-12T02:36:30.704Z","avatar_url":"https://github.com/SuperPaintman.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# babel-plugin-transform-pipeline\n\n[![Build][travis-image]][travis-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n[![Code Climate][codeclimate-image]][codeclimate-url]\n\n\n\u003e Compile pipeline operator (`|\u003e`) to ES5\n\n\n**Proposal**: [mindeavor/es-pipeline-operator][proposal-url]\n\n\n--------------------------------------------------------------------------------\n\n\n## Example\n### Basic\n\n**In**\n\n```javascript\nvar user = { name: 'SuperPaintman' };\n\nfunction capitalize(str) {\n  return str.toUpperCase();\n}\n\nfunction sayHello(name) {\n  return 'Hello, ' + name + '!';\n}\n\nvar res = user.name\n  |\u003e capitalize\n  |\u003e sayHello;\n\n// =\u003e \"Hello, SUPERPAINTMAN!\"\n```\n\n**Out**\n\n```javascript\nvar user = { name: 'SuperPaintman' };\n\nfunction capitalize(str) {\n  return str.toUpperCase();\n}\n\nfunction sayHello(name) {\n  return 'Hello, ' + name + '!';\n}\n\nvar res = sayHello(capitalize(user.name));\n\n// =\u003e \"Hello, SUPERPAINTMAN!\"\n```\n\n\n### With multi-argument functions\n\n**In**\n\n```javascript\nvar user = { score: 40.49138 };\n\nvar res = user.score\n  |\u003e (_ =\u003e _ * 2)\n  |\u003e (_ =\u003e _.toFixed(2));\n\n// =\u003e 80.98\n```\n\n**Out**\n\n```javascript\nvar user = { score: 40.49138 };\n\nvar res = (_ =\u003e _ * 2)((_ =\u003e _.toFixed(2))(user.score));\n\n// =\u003e 80.98\n```\n\n\n### Real use-case\n\n```javascript\nvar path = require('path');\n\nvar pathToUrl = (rootDir, filePath) =\u003e [rootDir, filePath]\n  |\u003e ((args) =\u003e path.relative(...args))\n  |\u003e path.dirname\n  |\u003e ((res) =\u003e res.split(path.sep).join(path.posix.sep))\n  |\u003e ((res) =\u003e '/' + (res === '.' ? '' : (res + '/')));\n\npathToUrl('./controllers', './controllers/api/users/index.js');\n// =\u003e \"/api/users/\"\n\npathToUrl('./controllers', './controllers/index.js');\n// =\u003e \"/\"\n```\n\n**Out**\n\n```javascript\nvar path = require('path');\n\nvar pathToUrl = (rootDir, filePath) =\u003e (res =\u003e '/' + (res === '.' ? '' : res + '/'))((res =\u003e res.split(path.sep).join(path.posix.sep))(path.dirname((args =\u003e path.relative(...args))([rootDir, filePath]))));\n\npathToUrl('./controllers', './controllers/api/users/index.js');\n// =\u003e \"/api/users/\"\n\npathToUrl('./controllers', './controllers/index.js');\n// =\u003e \"/\"\n```\n\n\n--------------------------------------------------------------------------------\n\n\n## FAQ\n\n\u003e Why do we need parentheses around multi-argument functions?\n\nBecause they separate the `=\u003e` from the `|\u003e`.\n\nIe. the following code:\n\n```javascript\nvar res = user.score\n  |\u003e _ =\u003e _ * 2\n  |\u003e double;\n```\n\nIs equivalent to:\n\n```javascript\nvar res = user.score\n  |\u003e _ =\u003e _ * double(2);\n\n\n// or\n\n\nvar secondArg = 2\n  |\u003e double;\n\nvar res = user.score\n  |\u003e _ =\u003e _ * secondArg;\n```\n\n\n\u003e Why `|\u003e`?\n\nFirstly, it is a invalid token in terms of javascript (*ES3*-*ES2017*).\n\nSecondly, in vanilla javascript there are only 3 token starting with `|`: `|`, `||` and `|=`;\n\n\n--------------------------------------------------------------------------------\n\n\n## Installation\n\n```sh\nnpm install --save-dev babel-plugin-transform-pipeline\n\n# or\n\nyarn add --dev babel-plugin-transform-pipeline\n```\n\n\n--------------------------------------------------------------------------------\n\n\n## Usage\n### Via `.babelrc` (Recommended)\n\n**.babelrc**\n\n```json\n{\n  \"plugins\": [\"transform-pipeline\"]\n}\n```\n\n\n### Via CLI\n\n```sh\nbabel --plugins transform-pipeline script.js\n```\n\n### Via Node API\n\n```javascript\nrequire(\"babel-core\").transform(\"code\", {\n  plugins: [\"transform-pipeline\"]\n});\n```\n\n\n--------------------------------------------------------------------------------\n\n## Build\n\n```sh\nnpm run build\n```\n\n\n--------------------------------------------------------------------------------\n\n## Test\n\n```sh\nnpm run test\n```\n\n\n--------------------------------------------------------------------------------\n\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/SuperPaintman/babel-plugin-transform-pipeline/fork\u003e)\n2. Create your feature branch (`git checkout -b feature/\u003cfeature_name\u003e`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin feature/\u003cfeature_name\u003e`)\n5. Create a new Pull Request\n\n\n\n--------------------------------------------------------------------------------\n\n\n## Contributors\n\n- [SuperPaintman](https://github.com/SuperPaintman) SuperPaintman - creator, maintainer\n\n\n--------------------------------------------------------------------------------\n\n\n## License\n\n[MIT][license-url]\n\n\n[license-url]: LICENSE\n[travis-image]: https://img.shields.io/travis/SuperPaintman/babel-plugin-transform-pipeline/master.svg?label=linux\n[travis-url]: https://travis-ci.org/SuperPaintman/babel-plugin-transform-pipeline\n[coveralls-image]: https://img.shields.io/coveralls/SuperPaintman/babel-plugin-transform-pipeline/master.svg\n[coveralls-url]: https://coveralls.io/r/SuperPaintman/babel-plugin-transform-pipeline?branch=master\n[codeclimate-image]: https://img.shields.io/codeclimate/github/SuperPaintman/babel-plugin-transform-pipeline.svg\n[codeclimate-url]: https://codeclimate.com/github/SuperPaintman/babel-plugin-transform-pipeline\n[proposal-url]: https://github.com/mindeavor/es-pipeline-operator\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuperpaintman%2Fbabel-plugin-transform-pipeline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuperpaintman%2Fbabel-plugin-transform-pipeline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuperpaintman%2Fbabel-plugin-transform-pipeline/lists"}