package replicant.messages;

import elemental2.core.JsObject;
import javax.annotation.Nonnull;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;
import jsinterop.base.Any;
import jsinterop.base.Js;

/**
 * A simple abstraction for key-value etag pairs.
 */
@JsType( isNative = true, name = "Object", namespace = JsPackage.GLOBAL )
public interface EtagsData
{
  /**
   * Return true if etag for channel is present.
   *
   * @param key the channel key.
   * @return true if the etag is present.
   */
  @JsOverlay
  default boolean containsChannel( @Nonnull final String key )
  {
    return Js.asPropertyMap( this ).has( key );
  }

  /**
   * Return the channels.
   *
   * @return eturn the channels.
   */
  @JsOverlay
  default String[] channels()
  {
    return JsObject.keys( this );
  }

  @Nonnull
  @JsOverlay
  default String getEtag( @Nonnull final String key )
  {
    final Any any = Js.asPropertyMap( this ).getAsAny( key );
    assert null != any;
    return any.asString();
  }
}

@@ -22,16 +22,48 @@
 sages;%0A%0A
+import elemental2.core.JsArray;%0A
 import e
@@ -857,34 +857,110 @@
     
-return JsObject.keys( this
+final JsArray%3CString%3E keys = JsObject.keys( this );%0A    return keys.asArray( new String%5B keys.length %5D
  );%0A

Upgrade to the latest Elemental2 API