I have such objects that I need to merge:
defaultConditions = where: enabled: true acc_id: ne: null conditions = where: id: 2 acc_id: ne: 5
This helper recipe, which replaces where
from defaultConditions
with where
from conditions
, is not quite right for this purpose. So I wrote this:
extend = (object, properties) ->
for key, val of properties
if val?.constructor is Object and object[key]?.constructor is Object
object[key] = extend object[key], val
else
object[key] = val
object
How can it be improved?