New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@koax/run

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@koax/run

Run a middleware stack.

latest
Source
npmnpm
Version
0.4.1
Version published
Maintainers
1
Created
Source

run

Build status Git tag NPM version Code style

Run a koax middleware stack.

This is the raw middleware stack runner. The basic principal of the runner is that values that are yielded in the middleware stack are dispatched back through the middleware stack to get resolved. yielded functors (arrays, generators, and iterators) aren't dispatched directly - instead the functors values are mapped, using predefined mapping functions, over the middleware stack.

Installation

$ npm install @koax/run

Usage

import run from '@koax/run'

let dispatch = run([
  function * (action, next) {
    if (action === 'foo') return 'bar'
    else if (action === 'qux') return yield 'foo'
    return next()
  },
  function * (action, next) {
    if (action === 'multi') return yield ['foo', 'qux']
    return next()
  }
])

dispatch('foo').then((res) => res) // => 'bar'
disaptch('qux').then((res) => res) // => 'bar'
disaptch('multi').then((res) => res) // => ['bar', 'bar']

API

run(middleware, ctx)

  • middleware - koax middleware array
  • ctx - ctx for middleware stack

Returns: dispatch function: dispatch(action, next)

License

MIT

FAQs

Package last updated on 03 Mar 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