# @sullux/fp-light-curry

> A lightweight functional library for functional composition and object composition.

Latest version **0.0.1** (published 2019-02-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sullux/fp-light-curry
pnpm add @sullux/fp-light-curry
yarn add @sullux/fp-light-curry
bun add @sullux/fp-light-curry
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2019-02-09 |
| First published | 2019-02-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.* |
| Dependencies | 0 |
| Unpacked size | 2.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Charles Sullivan |
| Maintainers | sullux |
| Keywords | fp, functional, curry |

## Links

- npm: https://www.npmjs.com/package/@sullux/fp-light-curry
- Repository: https://github.com/sullux/fp-light
- Homepage: https://github.com/Sullux/fp-light/blob/master/lib/curry/README.md
- Issues: https://github.com/sullux/fp-light/issues
- npm.io page: https://npm.io/package/@sullux/fp-light-curry

## Recent versions

- 0.0.1 (latest) — 2019-02-09

## README

[home](https://github.com/Sullux/fp-light/blob/master/README.md)

## fp-light-curry

`npm i @sullux/fp-light-curry`
[source](https://github.com/Sullux/fp-light/blob/master/lib/curry/curry.js)
[test](https://github.com/Sullux/fp-light/blob/master/lib/curry/curry.spec.js)

To _curry_ a function is to make it so that arguments can be progressively applied.

* [curry](#curry)

The following example demonstrates an uncurried function versus a manually curried function.

```javascript
const uncurriedAdd = (x, y) => x + y
uncurriedAdd(1, 2) // 3
uncurriedAdd(1) // NaN

const add = x => y => x + y
add(1)(2) // 3
add(1) // function
const increment = add(1)
increment(2) // 3
```

### curry

`curry(fn: Function, arity: ?Number): Function`

Returns a function that supports partial argument application. Note: the term "arity" means "number of arguments". If the `arity` is not supplied, the value of `fn.length` is used. Note that `fn.length` will not include optional or _rest_ arguments.

A vanilla example of currying:

```javascript
const add = curry((x, y) => x + y)
add(1, 2) // 3
const increment = add(1)
increment(2) // 3
```

An example showing that optional arguments are _not_ curried by default:

```javascript
// optional argument is not curried!
const mul = curry((x, y = 1) => x * y)
mul(2, 3) // 6
mul(2) // 2
```

An example using arity to explicitly curry an optional argument:

```javascript
const div = curry((x, y = 1) => x / y, 2) // note: arity 2 is explicit
div(6, 3) // 2
const half = div(2)
half(6) // 3
```

---
_Source: https://npm.io/package/@sullux/fp-light-curry · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
