# pipeop

> Simplest pipe operator alternative (11 lines of code) with the simplest and shortest syntaxt.

Latest version **1.0.0** (published 2020-01-21) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-01-21 |
| First published | 2020-01-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Szymon Wygnanski |
| Maintainers | sel |

## Links

- npm: https://www.npmjs.com/package/pipeop
- npm.io page: https://npm.io/package/pipeop

## Recent versions

- 1.0.0 (latest) — 2020-01-21

## README

# pipeop

Simplest pipe operator alternative (11 lines of code) with the simplest and shortest syntaxt.

## API

```js
pipe(initial:any, ...funcDefinitions:function[]|array[])
```

First argument is always an initial value. The rest argument are function definitions. A function definition can be a function or an array where the first argument is a function and the next are arguments.

## Examples

```js
function getUser() {
    return { userId: 'user-1' };
}

function addScoreToUser(user, score) {
    user.score = score;
    return user;
}

function addAgeToUser(user, age) {
    user.age = age;
    return user;
}

function makeItNice(user) {
    user.beard = true;
    return user;
}

// normally you would do this:
makeItNice(addAgeToUser(addScoreToUser(getUser(), 3), 37));

// with the pipe operator you can:
pipe(
    getUser(),
    [addScoreToUser, 3],
    [addAgeToUser, 37],
    makeItNice
);

const _ = require('underscore');

// no more _.chain()...value() with underscore/lodash
pipe(
    [1,2,3,4],
    [_.map, x => x * 2],
    [_.filter, x => x < 5]
);

// you can use async await with it as well
// promises are resolved and chained automatically
function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

(async () =>{
    pipe(
        1000,
        sleep,
        () => {
            console.log('ok1');
            return 1000;
        },
        sleep,
        () => console.log('ok2')
    );
})();

```

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