From 7f2d50347cec6379e0bc895963055f1bf2470cd7 Mon Sep 17 00:00:00 2001 From: Dan Wang Date: Sat, 10 Feb 2018 17:52:46 -0800 Subject: [PATCH] Add docs to README --- README.md | 11 ++++++++++- docs/functions.md | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 docs/functions.md diff --git a/README.md b/README.md index 4bca937..cd448ad 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ![Circle CI build status](https://circleci.com/gh/danwang/lambdanwang.svg?style=shield&circle-token=2299f0f86e45cf542f1855f46482c0e8dbe7b6f5) -Lambdanwang is a small library for functional programming in JavaScript and +Lambdanwang is a small library for functional programming with JavaScript and [Flow](https://flow.org/). @@ -13,6 +13,15 @@ Lambdanwang is a small library for functional programming in JavaScript and yarn add lambdanwang --save ``` +## Docs +### Containers +- [Option](https://github.com/danwang/lambdanwang/blob/master/docs/option.md) +- [Either](https://github.com/danwang/lambdanwang/blob/master/docs/either.md) + +### Functions +- [compose](https://github.com/danwang/lambdanwang/blob/master/docs/functions.md#compose) +- [mapObject](https://github.com/danwang/lambdanwang/blob/master/docs/functions.md#mapObject) + ## License [MIT License](https://github.com/danwang/lambdanwang/blob/master/LICENSE) diff --git a/docs/functions.md b/docs/functions.md new file mode 100644 index 0000000..d20022b --- /dev/null +++ b/docs/functions.md @@ -0,0 +1,22 @@ +# Functions + +## `compose` + +Performs function composition. +- `compose(f, g)` is equivalent to `(x) => f(g(x))` +- `compose(f, g, h)` is equivalent to `(x) => f(g(h(x)))` + +## `mapObject` +`(Iterable, (T) => [string, U]) => {[string]: U}` + +Given an Iterable and a mapper that returns a tuple, returns an object with the +tuples as key-value pairs. + +**Example:** +```jsx +// Returns {_foo_: 3, _barbaz_: 6} +λ.mapObject( + ['foo', 'barbaz'], + (s: string) => [`_${s}_`, s.length], +); +```