https://github.com/mtso/babel-plugin-transform-pipe-operator
Babel plugin to add Angularjs's transform pipe operator.
https://github.com/mtso/babel-plugin-transform-pipe-operator
babel operator pipe plugin
Last synced: 5 months ago
JSON representation
Babel plugin to add Angularjs's transform pipe operator.
- Host: GitHub
- URL: https://github.com/mtso/babel-plugin-transform-pipe-operator
- Owner: mtso
- License: mit
- Created: 2018-03-26T15:22:39.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-04-02T22:29:44.000Z (about 7 years ago)
- Last Synced: 2025-10-21T23:10:04.627Z (8 months ago)
- Topics: babel, operator, pipe, plugin
- Language: JavaScript
- Homepage:
- Size: 85 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# babel-plugin-transform-pipe-operator
Adds a pipe operator to call pure, synchronous transformer functions within JSX expressions.
## Example
A pipe inside a JSX expression,
```js
const Shout = ({ name }) => (
YO, { name | toUpperCase }!
);
```
Becomes a function call in the result:
```js
const Shout = ({ name }) => (
YO, { toUpperCase(name) }!
);
```
To pass a parameter, implement the transformer as a factory.
```js
const toFixed = (places) => (value) => value.toFixed(places);
const Cell = ({ value }) => (
{ value | toFixed(2) }
);
```
```js
const toFixed = (places) => (value) => value.toFixed(places);
const Cell = ({ value }) => (
{ toFixed(2)(value) }
);
```