Created
October 4, 2015 18:45
-
-
Save raine/0f640866e0a5f0a24e04 to your computer and use it in GitHub Desktop.
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 { pickBy } = require('ramda'); | |
const obj = { | |
a: 1, | |
b: 2, | |
A: 3, | |
B: 4 | |
}; | |
// --- | |
const keyIsUpperCase = (val, key) => | |
key.toUpperCase() === key; | |
pickBy(keyIsUpperCase, obj); | |
// --- | |
const focus = (idx, fn) => | |
(...args) => fn(args[idx]); | |
const isUpperCase = (str) => | |
str.toUpperCase() === str; | |
const keyIsUpperCase_ = focus(1, isUpperCase); | |
pickBy(focus(1, isUpperCase), obj); // { A: 3, B: 4 } | |
pickBy(keyIsUpperCase_, obj); // { A: 3, B: 4 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment