Skip to content

Add RequestInit#duplex #719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api-reports/2_12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16510,6 +16510,7 @@ Request[JC] def bodyUsed: Boolean
Request[JC] def cache: RequestCache
Request[JC] def credentials: RequestCredentials
Request[JC] def destination: RequestDestination
Request[JC] def duplex: RequestDuplex
Request[JC] def formData(): js.Promise[FormData]
Request[JC] def headers: Headers
Request[JC] def integrity: String
Expand Down Expand Up @@ -16542,6 +16543,8 @@ RequestDestination[SO] val sharedworker: RequestDestination
RequestDestination[SO] val subresource: RequestDestination
RequestDestination[SO] val unknown: RequestDestination
RequestDestination[SO] val worker: RequestDestination
RequestDuplex[JT]
RequestDuplex[SO] val half: RequestDuplex
RequestInit[JT] var body: js.UndefOr[BodyInit]
RequestInit[JT] var cache: js.UndefOr[RequestCache]
RequestInit[JT] var credentials: js.UndefOr[RequestCredentials]
Expand Down
3 changes: 3 additions & 0 deletions api-reports/2_13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16510,6 +16510,7 @@ Request[JC] def bodyUsed: Boolean
Request[JC] def cache: RequestCache
Request[JC] def credentials: RequestCredentials
Request[JC] def destination: RequestDestination
Request[JC] def duplex: RequestDuplex
Request[JC] def formData(): js.Promise[FormData]
Request[JC] def headers: Headers
Request[JC] def integrity: String
Expand Down Expand Up @@ -16542,6 +16543,8 @@ RequestDestination[SO] val sharedworker: RequestDestination
RequestDestination[SO] val subresource: RequestDestination
RequestDestination[SO] val unknown: RequestDestination
RequestDestination[SO] val worker: RequestDestination
RequestDuplex[JT]
RequestDuplex[SO] val half: RequestDuplex
RequestInit[JT] var body: js.UndefOr[BodyInit]
RequestInit[JT] var cache: js.UndefOr[RequestCache]
RequestInit[JT] var credentials: js.UndefOr[RequestCredentials]
Expand Down
13 changes: 13 additions & 0 deletions dom/src/main/scala-2/org/scalajs/dom/RequestDuplex.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.scalajs.dom

import scala.scalajs.js

/**
* Fetch APIs [[https://fetch.spec.whatwg.org/#dom-requestinit-duplex RequestDuplex enum]]
*/
@js.native
sealed trait RequestDuplex extends js.Any

object RequestDuplex {
val half: RequestDuplex = "half".asInstanceOf[RequestDuplex]
}
12 changes: 12 additions & 0 deletions dom/src/main/scala-3/org/scalajs/dom/RequestDuplex.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.scalajs.dom

import scala.scalajs.js

/**
* Fetch APIs [[https://fetch.spec.whatwg.org/#dom-requestinit-duplex RequestDuplex enum]]
*/
opaque type RequestDuplex <: String = String

object RequestDuplex {
val half: RequestDuplex = "half"
}
5 changes: 5 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/Request.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@ class Request(input: RequestInfo, init: RequestInit = null) extends Body {
def keepalive: Boolean = js.native

def signal: AbortSignal = js.native

/** "half" is the only valid value and it is for initiating a half-duplex fetch (i.e., the user agent sends the entire
* request before processing the response).
*/
def duplex: RequestDuplex = js.native
}