Socket
Socket
Sign inDemoInstall

composition

Package Overview
Dependencies
2
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    composition

Compose generator and async/await middleware


Version published
Weekly downloads
8.4K
increased by10.93%
Maintainers
2
Install size
47.0 kB
Created
Weekly downloads
 

Readme

Source

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);
})

Keywords

FAQs

Last updated on 28 Feb 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc