# plumb

> functional composition sugar

Latest version **0.1.0** (published 2013-04-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install plumb
pnpm add plumb
yarn add plumb
bun add plumb
```

## 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.1.0 |
| Published | 2013-04-29 |
| First published | 2013-04-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Agile Diagnosis |
| Maintainers | jden |
| Keywords | functional, compose, composition |

## Links

- npm: https://www.npmjs.com/package/plumb
- Repository: git@github.com:AgileDiagnosis/plumb
- npm.io page: https://npm.io/package/plumb

## Recent versions

- 0.1.0 (latest) — 2013-04-29

## README

# plumb
functional composition sugar

## usage

    var plumb = require('plumb')

    var reverseString = plumb(
      plumb.invoke('split')
      plumb.invoke('reverse')
      plumb.invoke('join','')
    )
    // => Function

    reverseString('hello')
    // => "olleh"

## api

Using [jsig notation](https://github.com/jden/jsig)

### `plumb(...fns: Function) => (val: Value) => Value`

Reutrns a function composing each of the argument functions in order. The return value of each function is used as the argument for each successive function.

### `plumb.pipe(val: Value, ...fns: Function) => Value`

Immediately invoke a composition of functions `fns` on the value `val`. It helps me to think about `fns` as a crazy pachinko machine and `val` as the ball going in.

Equivalent to `plumb(fns)(val)`

### `plumb.invoke(methodName: String, ...args?: Value) => Function`

Creates a function which invokes a method on an object, optionally with fixed arguments.

Example:

    plumb.invoke('foo','bar')

returns the equivalent of

    function callFoo(obj) {
      return obj.foo('bar')
    }

### `plumb.tap(fn: Function) => (Value) => Value`

Create a function which passes a value through (identity) and calls a function `fn` with that value.

Example:

    var log = plumb.tap(function (x) { console.log(x)})

    log(10)
    // => 10
    // side effect: console.log(10) was called

## installation

    $ npm install plumb

## running the tests

From project root:

    $ npm install
    $ npm test

## contributors

jden <jason@denizac.org>

## license

MIT. (c) 2013 Agile Diagnosis <hello@agilediagnosis.com> See LICENSE.md

"...and visions of sugarplums danced in their heads"

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