# hook-pipeline

> Hook based approach to transform data in a pipeline

Latest version **0.0.4** (published 2018-05-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install hook-pipeline
pnpm add hook-pipeline
yarn add hook-pipeline
bun add hook-pipeline
```

## 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.4 |
| Published | 2018-05-11 |
| First published | 2018-05-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Matt Chaffe |
| Maintainers | mattchewone |

## Links

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

## Recent versions

- 0.0.4 (latest) — 2018-05-11
- 0.0.3 — 2018-05-10
- 0.0.2 — 2018-05-10
- 0.0.1 — 2018-05-10

## README

# Hook Pipelines

### Pipeline processing shamelessly based off [Feathers](https://github.com/feathersjs/feathers) hooks flow

Working example:
```js
const pipeline = require('hook-pipeline')

// Initialise
const output = await pipeline()
  // Run jobs here
  .process([
    context => {
      if (context.data[0].name === 'Matt') {
        context.error.push(new Error('Name === Matt'))
      }
      return context
    },

    context => {
      return request.get('http://example.com')  
        .then(res => {
          context.data[0].name = res.name
          return context
        })
    }
  ])
  .run({ name: 'Matt' })

// output contains data which has been processed and any errors you may have pushed into the hook context
// output.data === { name: 'Matt' }
// output.error === [{ new Error('msg') }]
```

### Skipping
If your process failed or you wish to stop running any more hooks, set the return value from your function to '__skip'

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