Created
April 26, 2021 07:04
-
-
Save dmshvetsov/31aa12dff753dbb5514345276d9a55af to your computer and use it in GitHub Desktop.
Do if values exist pattern
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
function doIfExist(obj, predicateValuesPaths, fn) { | |
const values = predicateValuesPaths.map((keyPath) => get(obj, keyPath)) | |
if (all(values, truthy)) { | |
return fn(...values) | |
} | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment