Skip to content

floxjs/yoco

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yoco

Build status Git tag NPM version Code style

Your custom co routines. Use redux middleware to define custom yield behavior, using redux-flo for control flow.

Installation

$ npm install yoco

Usage

import yoco from 'yoco'
import rlog from 'redux-log'

let arr = []
let log = yoco(rlog(arr))

log(function * () {
  yield 'hello'
  yield 'world'
})

arr // => ['hello', 'world']

API

yoco(mw)

  • mw - redux middleware or array of middleware

Returns: a custom co routine runner

map(fns)

  • fns - functions to perform left to right composition over

Returns: a custom co routine runner

import {map} from 'yoco'
let wacky = map(wackify)

wacky(function * () {
  yield 'happy' // => 'wacky happy'
  yield ['dog', 'cat'] // => ['wacky dog', 'wacky cat']
})

function wackify (str) {
  return 'wacky ' + str
}

License

MIT