Echo JS 0.11.0

<~>
planttheidea 2741 days ago. link 1 point
Based on your use of isNil, you consider null to be an invalid value, not just undefined? Is there a reason you differ from the spec?

Replies

jth0024 2741 days ago. link 1 point
Good question! I assumed that most people using this library would use it to handle missing arguments in their functions. Based on that common use-case, I expect that null and Undefined are both considered "missing" arguments. That being said, I anticipated that this might not work for every use-case, so I allow you to write your own customizer if that behavior is not ideal.
xat 2741 days ago. link 1 point
You can check for the existence of a property with obj.hasOwnProperty('someProp').
jth0024 2741 days ago. link 1 point
Yep, you can. But like I said, if I were only hoping to apply default values for missing properties I would just use Object.assign like others have suggested. Instead, I wanted the ability to use any conditional check that I choose when merging values, and I wrote this library because I've frequently needed to write little wrappers that used Object.assign to do that. It's useful to me because it provides an easy way to perform common tasks with less code. I didn't write the library because I'm unfamiliar with ES2015 or the Object API.