Skip to content

Instantly share code, notes, and snippets.

@dmshvetsov
Created April 26, 2021 07:04
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 dmshvetsov/31aa12dff753dbb5514345276d9a55af to your computer and use it in GitHub Desktop.
Save dmshvetsov/31aa12dff753dbb5514345276d9a55af to your computer and use it in GitHub Desktop.
Do if values exist pattern
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