0.0.4 • Published 6 years ago

hook-pipeline v0.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

Hook Pipelines

Pipeline processing shamelessly based off Feathers hooks flow

Working example:

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'

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago