Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

composition

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

composition

Compose generator and async/await middleware

  • 2.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
18K
increased by51.1%
Maintainers
2
Weekly downloads
 
Created
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

Package last updated on 28 Feb 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc