hook-pipeline
v0.0.4
Published
Hook based approach to transform data in a pipeline
Downloads
133
Readme
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'