Skip to content
Raine Virta edited this page Jun 1, 2015 · 40 revisions

Feel free to contribute to this document with ramda-cli snippets that have helped you.

Recipes

Create a markdown formatted table of Ramda's functions

Output from ramda-cli can be piped to markdown-cli-table to create a Markdown formatted table.

npm install -g markdown-table-cli
curl -s https://raine.github.io/ramda-json-docs/latest.json | \
  R 'project <[ name sig category ]>' \
    'map evolve sig: (-> it and "`#it`"), name: -> "[`#it`](http://ramdajs.com/docs/##it)"' \
  | md-table
name sig category
add Number -> Number -> Number Math
adjust (a -> a) -> Number -> [a] -> [a] List
always a -> (* -> a) Function
aperture Number -> [a] -> [[a]] List

Merge JSON files into a single object

cat *.json | R --slurp merge-all

Unwrap a list of objects into Line Delimited JSON

cat data.json | R --unslurp --compact identity

Read filenames from stdin as an object of {filename: body}

find . -name '*.txt' | R -r --slurp 'map -> (it): read-file it' merge-all

Inspect MongoDB collection as a table

Install flat to $HOME/node_modules. It's used to flatten a deep structure into a shallow object.

mongoexport -d test -c zips --jsonArray -q '{state: "NY"}' --sort '{pop: -1}' |\
  R 'map require \flat' -o table | less

Data: http://media.mongodb.org/zips.json

The result looks something like this:

Clone this wiki locally