TODO
- [ ] Coverage reporting - coveralls
- [ ] Commit message validation - validate-commit-msg
- [ ] Semantic release - sematic-release
npm install @sidefx/core --save
https://unpkg.com/@sidefx/core
// SideFx is a minimal interface to make development
// with purely functional code easier and testable
import {fx, inject} from '@sidefx/core'
// declare custom effects.
// must returns a function
const mySideEffect = (value) => {
const effect = () => {
global.crazySideEffects(value)
console.log(`Hello ${value}`)
}
effect.value = value
return effect
}
// define injections, DRY
inject({ myState: '!' })
// then code with pure functions.
// injections passed as first parameter
const myFunction = fx(({ myState }, value) => {
return [ mySideEffect(value + myState) ]
})
// get returned values without
// executing the side effects
console.log(myFunction.pure('Mars'))
// -> [function effect()]
console.log(myFunction.pure('Mars')[0].value)
// -> 'Mars!'
// or just run the function
// to execute the side effects
myFunction('Earth')
// -> 'Hello Earth!'