Skip to content

Latest commit

 

History

History
33 lines (23 loc) · 1.04 KB

no-pipeline-operator.md

File metadata and controls

33 lines (23 loc) · 1.04 KB

no-pipeline-operator

This prevents the use of the Pipeline Operator

const result = "hello" |> capitalize |> exclaim

These will not be allowed because they are not supported in the following browsers:

  • Edge (any version at the time of writing)
  • Safari (any version at the time of writing)
  • Firefox (any version at the time of writing)
  • Chrome (any version at the time of writing)

What is the Fix?

For simple expressions you can wrap each function inside the previous pipeline call:

// these are equivalent:
const result = "hello" |> capitalize |> exclaim
const result = exclaim(capitalize("hello"))

Lastly, you could consider using a utility function such as lodash' _.flow or _.flowRight

const result = _.flow(capitalize, exclaim)("hello")
const result = _.flowRight(exclaim, capitalize)("hello")

This can be safely disabled if you intend to compile code with the @babel/plugin-proposal-pipeline-operator Babel plugin.