Skip to content

Commit

Permalink
Add docs to README
Browse files Browse the repository at this point in the history
  • Loading branch information
danwang committed Feb 11, 2018
1 parent 921dc2a commit 7f2d503
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).


Expand All @@ -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)
22 changes: 22 additions & 0 deletions docs/functions.md
Original file line number Diff line number Diff line change
@@ -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`
`<T, U>(Iterable<T>, (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],
);
```

0 comments on commit 7f2d503

Please sign in to comment.