1. 15
  1.  

  2. 4

    I had trouble thinking of use-cases for this. When might a key be missing?

    I guess one use-case would be interacting with an API where some of the returned data is optional. For example, if you are looking up the weather at a location, you might call .path('rain.amount').get() on the returned JSON to see whether to describe it as “light” or “heavy” rain. To handle the case of there being no rain at all, you can check for undefined being returned instead of having to catch a missing key error.

    1. 4

      That one use case describes a great deal of my daily work. :-)

      In addition to optional data from an API, I sometimes use “live” objects that start off empty and then update themselves with the result of an API call. The data will eventually exist on the object, but may not at the moment it is being inspected, so using a library like this would simplify dealing with deeply nested data on those live objects.

      1. 2

        Wow, this looks great.