composition
Compose generator and async/await middleware
Last updated 10 years ago by jongleberry .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install composition 
SYNC missed versions from official npm registry.

composition

NPM version Build status Test coverage Dependency Status License Downloads

Compose generator and async/await middleware like koa. Allows to use both generator functions and async/await functions.

var compose = require('composition');

var stack = [];

// generator functions
stack.push(function* (next) {
  yield next;
});

// regular functions that return anything
// but they should be promises!
stack.push(function (next) {
  return Promise.resolve(true);
});

// async/await functions
stack.push(async function (next) {
  return await Promise.resolve(true);
});

// compose it into a function
var fn = compose(stack);

// this function returns a promise
fn.call(this).then(function (val) {
  console.log(val);
}).catch(function (err) {
  console.error(err.stack);
  process.exit(1);
})

Current Tags

  • 2.3.0                                ...           latest (9 years ago)

9 Versions

  • 2.3.0                                ...           9 years ago
  • 2.2.1                                ...           9 years ago
  • 2.2.0                                ...           9 years ago
  • 2.1.2                                ...           9 years ago
  • 2.1.1                                ...           10 years ago
  • 2.1.0                                ...           10 years ago
  • 2.0.1                                ...           10 years ago
  • 2.0.0                                ...           10 years ago
  • 1.0.0                                ...           11 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (4)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |