Do you...

...use a functional library, like lodash, underscore, or ramda in every project?

Do you...

...find this code hard to follow?

callback( _.flatten( 
  _.compact( _.flatten(myArray) ).map(function(item){ 
    return JSON.stringify( 
      Math.pow( parseInt(item) * 100, 2 )
    ).replace(/0+/, ''); 
  })
));

Do you...

...not want to learn a whole new language, throwing away most of your JavaScript skills?

callback( _.flatten( 
  _.compact( _.flatten(myArray) ).map(function(item){ 
    return JSON.stringify( 
      Math.pow( parseInt(item) * 100, 2 )
    ).replace(/0+/, ''); 
  })
));
my-array
  |> flatten
  |> compact
  |> map ->
    it
      |> parse-int
      |> (* 100)
      |> (** 2)
      |> JSON.stringify
      |> (.replace /0+/, '')
  |> flatten
  |> callback

LiveScript!

Much more obvious control flow 

my-array
  |> flatten
  |> compact
  |> map ->
    it
      |> parse-int
      |> (* 100)
      |> (** 2)
      |> JSON.stringify
      |> (.replace /0+/, '')
  |> flatten
  |> callback

A functional standard library!

my-array
  |> flatten
  |> compact
  |> map ->
    it
      |> parse-int
      |> (* 100)
      |> (** 2)
      |> JSON.stringify
      |> (.replace /0+/, '')
  |> flatten
  |> callback

flatten, compact, and many, many other useful functions have been pulled from Haskell

Flexible learning curve

callback( flatten( 
  compact( flatten(myArray) ).map( (item) -> 
    return JSON.stringify( 
      Math.pow( parseInt(item) * 100, 2 )
    ).replace(/0+/, ''); 
  )
));

unlike ClojureScript, you don't have to start from scratch and learn a whole new language before you can be productive

callback( _.flatten( 
  _.compact( _.flatten(myArray) ).map(function(item){ 
    return JSON.stringify( 
      Math.pow( parseInt(item) * 100, 2 )
    ).replace(/0+/, ''); 
  })
));

LiveScript

when your skills are growing

faster than JavaScript is

learnxinyminutes.com/docs/livescript

LiveScript

By Chris Fritz

LiveScript

  • 1,679