Last active
January 5, 2018 18:30
-
-
Save carlesba/f604548ecaa9e0a9fe56c1de469144d7 to your computer and use it in GitHub Desktop.
passby: look into a pipe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/carlesba/immootable/blob/master/src/pass-by.js