-
-
Save taroyanaka/aaf1770529b33f2f3cf513d78f7cd4ff to your computer and use it in GitHub Desktop.
ramda: has, path, propOr, pathOr, keys, values
This file contains 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
import { has, path, propOr, pathOr, keys, values } from "ramda" | |
const one = { | |
a: "Bingo", | |
b: { | |
c: "Bingo", | |
}, | |
} | |
const two = { | |
d: "Bingo", | |
e: { | |
f: "Bingo", | |
}, | |
} | |
console.log("one has a?", has("a", one)) | |
console.log("value of c?", path(["b", "c"], one)) | |
console.log("one, a or Not found?", propOr("Not found", "a", one)) | |
console.log("two, a or Not found?", propOr("Not found", "a", two)) | |
console.log("f or Not found?", pathOr("Not found", ["e", "f"], one)) | |
console.log("f or Not found?", pathOr("Not found", ["e", "f"], two)) | |
console.log("one keys", keys(one)) | |
console.log("one values", values(one)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment