Skip to content

Instantly share code, notes, and snippets.

@carlesba
Last active January 5, 2018 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlesba/f604548ecaa9e0a9fe56c1de469144d7 to your computer and use it in GitHub Desktop.
Save carlesba/f604548ecaa9e0a9fe56c1de469144d7 to your computer and use it in GitHub Desktop.
passby: look into a pipe
const passBy = by => pass => {
by(pass)
return pass
}
/*
Example:
///////////////////
const log = console.log
const get = (attribute, target) => target[attribute]
const getName = get('name')
const getUser = get('user')
const getUserName = combine(
getName,
passBy(log),
getUser
)
const state = { user: { name: 'snitch' } }
const name = getUserName(state)
// log: { name: 'snitch' } }
// name === 'snitch'
*/
@carlesba
Copy link
Author

carlesba commented Jan 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment