code: function serialize(caps) {
    let ret = {};
    for (let key of caps.keys()) {
      let cap = caps.get(key);
      if (cap !== undefined && cap !== null) {
        ret[key] = cap;
      }
    }
    return ret;
  }
docs: Serializes a capabilities object. This is defined as a standalone function
  so it may be type checked (where Capabilities[Symbols.serialize] has type
  checking disabled since it is defined with [] access on a struct).
  
  @param {!Capabilities} caps The capabilities to serialize.
  @return {!Object<string, ?>} The JSON representation of this instance.
  Note, the returned object may contain nested promised values.