1.1.2 • Published 9 years ago

ensue v1.1.2

Weekly downloads
15
License
MIT
Repository
github
Last release
9 years ago

ensue

NPM version Unix Build Status Windows Build Status Coveralls Status Dependency Status

Ensue performs left-to-right function composition and works like the pipe operator, more common in functional programming languages.

Ensue turns

const seo = data => c(b(a(data)))

into linear form

seq=P( a, b, c )

seq( data )

or even array for steps

seq= a, b, c

ensue( seq )( data )

Also lib supports nested array of pipes, so you can describe your sequences as simple function lists

Install

npm install --save ensue

Usage

Let's write some short sequences

import E from 'ensue'
import R from 'ramda'

//Simple validation
const hasStringId = [
  R.propOr(null,'id'),
  R.is(String)
]
//Another sequence: selector
const getUsers = [
  R.prop('users'),
  R.values,
  R.reject( R.has('inactive') )
]

Now we can use composition to get new sequences

const checkLastId = [
  getUsers,
  R.last,
  hasStringId
]

//Make native function with ensue
const validator = E(checkLastId)

function stateToProps(state) {
  return {
    flag: validator(store)
  }
}

License

MIT © Zero Bias

1.1.2

9 years ago

2.0.1-beta.0

9 years ago

1.1.1

9 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.5

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.0

9 years ago