GeZe
[0] https://flow.org/try/#0C4TwDgpgBAggxsAlgewHZQLwCgq6gHygG8oBr...
Docs for enums compilation/runtime are here: https://flow.org/en/docs/enums/defining-enums/#toc-enums-at-...
Scaling Flow to tens of millions of lines of JavaScript with Types-First mode
For instance changing all calls to "calc" from taking two arguments to taking one object literal instead (eg. `calc(1, 2)` to `calc({from: 1, to: 2})`, is as easy as:
$ grasp -r -e 'calc($a, $b)' -R 'calc({from: {{a}}, to: {{b}}})' file.js
(Where the two arguments to "calc" could be any arbitrary nested expressions, which could not be safely handled by a regular expression)You can use both CSS style selectors, and pattern matching, to both search and replace your code.
Refactoring your JavaScript code with Grasp
Grasp has two different query types, the default, squery - selector query, CSS style selectors, and equery (-e, --equery) - example query, JS code examples with wildcards.
In the grasp example above, we are using squery. jsgrep is similar to equery. You could do the following search in equery, and it would be more equivalent to the example you posted:
f(__ < __, __ == __)
The only thing missing is the named wildcards for easy replace - that's a good idea and a feature to add to grasp 0.2.0!You can check out the docs on squery (http://graspjs.com/docs/squery/) and equery (http://graspjs.com/docs/equery/)
PS. If anyone has any questions about grasp please let me know!
eg.
getUserFriends = (userName) ->
user <- findUser userName
friends <- findFriends user
...
Specifically, the section on "backcalls": http://livescript.net/#backcalls totals = map (.total), orders
http://livescript.net/It covers first class and higher order functions, currying, partial application, composing functions, using operators as functions, comprehensions, and immutability.
a <- doFirstThing()
b, c <- doSecondThing(a)
doFinalThing(b + c)LiveScript hasn't been used as a name for JavaScript in almost two decades.
I would suggest http://learnyouahaskell.com/
I think many JavaScript programmers are looking for JavaScript (CoffeeScript) + functional programming rather than something purely functional as it allows them to use all that they've learned and mastered from JavaScript (often in an enhanced way) while using functional concepts as they learn them.
Functional Programming in JavaScript using LiveScript and prelude.ls: http://livescript.net/blog/functional-programming-in-javascr...
[1 to 100]map(->[s for s,n of{Fizz:3,Buzz:5}|it%n<1]*''||it)
Unlike CoffeeScript, but like Python, it has proper list comprehensions `["#x#y" for x in [\a \b] for y in [1 2]]` which I think is very important to any Python fan, dict comprehensions, and (more minor) you can use `is not`, like in Python, instead of `isnt`. (Along with many other features.)
Part 1 discussion on HN: http://news.ycombinator.com/item?id=4135616