Skip to content

Instantly share code, notes, and snippets.

@FabioAntunes
Created March 25, 2018 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FabioAntunes/4fab31ab14955549c47288a255e52e8d to your computer and use it in GitHub Desktop.
Save FabioAntunes/4fab31ab14955549c47288a255e52e8d to your computer and use it in GitHub Desktop.
Example of Pipeline Operator proposal
// Some functions that do string operations
function doubleSay (str) {
return str + ", " + str;
}
function capitalize (str) {
return str[0].toUpperCase() + str.substring(1);
}
function exclaim (str) {
return str + '!';
}
// old way
let result = exclaim(capitalize(doubleSay("hello")));
result //=> "Hello, hello!"
// with the new pipeline operator
let result = "hello"
|> doubleSay
|> capitalize
|> exclaim;
result //=> "Hello, hello!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment