module.exports = setIfExists

function setIfExists (object, key, value) {
  if (!object) {
    return
  }

  if (key in object) {
    object[key] = typeof value === 'function' ? value(object[key]) : value
  }
}

@@ -23,16 +23,85 @@
 Exists%0A%0A
+const get = require('lodash/get')%0Aconst set = require('lodash/set')%0A%0A
 function
@@ -175,44 +175,115 @@
 %0A%0A  
-if (key in object) %7B%0A    object%5Bkey%5D
+const currentValue = get(object, key)%0A%0A  if (currentValue === undefined) %7B%0A    return%0A  %7D%0A%0A  const newValue
  = t
@@ -321,19 +321,20 @@
 lue(
-object%5Bkey%5D
+currentValue
 ) : 
@@ -339,14 +339,40 @@
 : value%0A
+%0A
   
-%7D
+set(object, key, newValue)
 %0A%7D%0A

set nested property if exists