![entrust](https://cdn.rawgit.com/brekk/entrust/88ecfa3/logo.svg)

> Delegatee-last curried functions for great justice

[![Greenkeeper badge](https://badges.greenkeeper.io/brekk/entrust.svg)](https://greenkeeper.io/)

You can use `entrust` to easily make most functions into a curried, delegatee-last (data-last) form. If you are used to functional programming (FP) paradigms, this makes FP in JS much easier.

Example:

```js
// native map looks like: array.map(fn)
// entrust map looks like: e1(`map`, fn, array)
import {e1} from 'entrust'
const map = e1(`map`) // this takes a function first, and then the data
map(x => x * 2, [1,2,3]) // [2,4,6]
```

Here's an example of how to apply the same approach to a tertiary function, like `reduce`:

```js
import {e2} from 'entrust'
// native reduce looks like: array.reduce(fn, initial)
const reduce = e2(`reduce`) // e2(`reduce`, fn, initial, array)
const sum = reduce((a, b) => a + b, 0)
sum([1,2,3]) // 6
sum([1,2,3,4]) // 10
sum([1,2,3,4,5]) // 15
```

_NB: This approach is used extensively in the `f-utility` module. You may want to take a look at it [here](https://www.npmjs.com/package/f-utility)._

# API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

## e0

**Parameters**

-   `fn` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** a function name
-   `x` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an object

**Examples**

```javascript
import {e0} from 'entrust'
const toLowerCase = e0(`toLowerCase`)
toLowerCase(`COOL`) // cool
```

Returns **any** 

## e1

**Parameters**

-   `fn` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** a function name
-   `a` **any** some parameter
-   `x` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an object

**Examples**

```javascript
import {e1} from 'entrust'
const split = e1(`split`)
split(`:`, `c:o:o:l`) // [`c`,`o`,`o`,`l`]
```

Returns **any** 

## e10

**Parameters**

-   `fn` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** a function name
-   `a` **any** some parameter
-   `b` **any** some parameter
-   `c` **any** some parameter
-   `d` **any** some parameter
-   `e` **any** some parameter
-   `f` **any** some parameter
-   `g` **any** some parameter
-   `h` **any** some parameter
-   `i` **any** some parameter
-   `j` **any** some parameter
-   `x` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an object

Returns **any** 

## e2

**Parameters**

-   `fn` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** a function name
-   `a` **any** some parameter
-   `b` **any** some parameter
-   `x` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an object

**Examples**

```javascript
import {e2} from 'entrust'
const replace = e2(`replace`)
replace(`old`, `new`, `oldnew`) // newnew
```

Returns **any** 

## e3

**Parameters**

-   `fn` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** a function name
-   `a` **any** some parameter
-   `b` **any** some parameter
-   `c` **any** some parameter
-   `x` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an object

Returns **any** 

## e4

**Parameters**

-   `fn` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** a function name
-   `a` **any** some parameter
-   `b` **any** some parameter
-   `c` **any** some parameter
-   `d` **any** some parameter
-   `x` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an object

Returns **any** 

## e5

**Parameters**

-   `fn` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** a function name
-   `a` **any** some parameter
-   `b` **any** some parameter
-   `c` **any** some parameter
-   `d` **any** some parameter
-   `e` **any** some parameter
-   `x` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an object

Returns **any** 

## e6

**Parameters**

-   `fn` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** a function name
-   `a` **any** some parameter
-   `b` **any** some parameter
-   `c` **any** some parameter
-   `d` **any** some parameter
-   `e` **any** some parameter
-   `f` **any** some parameter
-   `x` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an object

Returns **any** 

## e7

**Parameters**

-   `fn` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** a function name
-   `a` **any** some parameter
-   `b` **any** some parameter
-   `c` **any** some parameter
-   `d` **any** some parameter
-   `e` **any** some parameter
-   `f` **any** some parameter
-   `g` **any** some parameter
-   `x` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an object

Returns **any** 

## e8

**Parameters**

-   `fn` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** a function name
-   `a` **any** some parameter
-   `b` **any** some parameter
-   `c` **any** some parameter
-   `d` **any** some parameter
-   `e` **any** some parameter
-   `f` **any** some parameter
-   `g` **any** some parameter
-   `h` **any** some parameter
-   `x` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an object

Returns **any** 

## e9

**Parameters**

-   `fn` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** a function name
-   `a` **any** some parameter
-   `b` **any** some parameter
-   `c` **any** some parameter
-   `d` **any** some parameter
-   `e` **any** some parameter
-   `f` **any** some parameter
-   `g` **any** some parameter
-   `h` **any** some parameter
-   `i` **any** some parameter
-   `x` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an object

Returns **any** 

## eN

invoke a delegated method with arguments as an array. enforces specific arity

**Parameters**

-   `n` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** 0 - 10
-   `method` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** a function name on your delegatee
-   `args` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** arguments to pass to your delegatee's method
-   `delegatee` **any** something with methods

**Examples**

```javascript
import {eN} from 'entrust'
eN(0, `toUpperCase`, [], `cool`) // `COOL`
eN(1, `map`, [(x) => x * 2], [1,2,3]) // [2,4,6]
eN(2, `reduce`, [(a, b) => (a + b), 0], [1,2,3]) // 6
```

Returns **any** the result of delegating to the method with some arguments

## eD

invoke a delegated method with arguments as an array. enforces specific arity
Yells at you if you give arguments that don't match the expected arity.

**Parameters**

-   `n` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** 0 - 10
-   `method` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** a function name on your delegatee
-   `args` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** arguments to pass to your delegatee's method
-   `delegatee` **any** something with methods

**Examples**

```javascript
import {eD} from 'entrust'
eD(0, `toUpperCase`, [], `cool`) // `COOL`
eD(1, `map`, [(x) => x * 2], [1,2,3]) // [2,4,6]
eD(2, `reduce`, [(a, b) => (a + b), 0], [1,2,3]) // 6
eD(2, `reduce`, [(a, b) => (a + b)], [1, 2, 3]) // throws error
```

Returns **any** the result of delegating to the method with some arguments
