Skip to content

Make reason for Readable/WritableStream cancel/abort optional #496

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 2 commits into from
Aug 22, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions api-reports/2_12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ experimental/PointerLock.PointerLockDocument[JT] def pointerLockElement: Element
experimental/PointerLock.PointerLockElement[JT] def requestPointerLock(): Unit
experimental/PointerLock.PointerLockMouseEvent[JT] def movementX: Double
experimental/PointerLock.PointerLockMouseEvent[JT] def movementY: Double
experimental/ReadableStream[JT] def cancel(reason: String): js.Promise[Any]
experimental/ReadableStream[JT] def cancel(reason: js.UndefOr[Any] = js.undefined): js.Promise[Unit]
experimental/ReadableStream[JT] def getReader(): ReadableStreamReader[T]
experimental/ReadableStream[JT] def locked: Boolean
experimental/ReadableStream[JT] def pipeThrough[U](pair: Any, options: Any = js.undefined): ReadableStream[U]
Expand Down Expand Up @@ -469,7 +469,7 @@ experimental/WriteableState[SO] val closing = "closing".asInstanceOf[WriteableSt
experimental/WriteableState[SO] val errored = "errored".asInstanceOf[WriteableState]
experimental/WriteableState[SO] val waiting = "waiting".asInstanceOf[WriteableState]
experimental/WriteableState[SO] val writable = "writable".asInstanceOf[WriteableState]
experimental/WriteableStream[JT] def abort(reason: Any): Unit
experimental/WriteableStream[JT] def abort(reason: js.UndefOr[Any] = js.undefined): js.Promise[Unit]
experimental/WriteableStream[JT] def close(): js.Promise[WriteableStream[T]]
experimental/WriteableStream[JT] val closed: js.Promise[WriteableStream[T]]
experimental/WriteableStream[JT] val ready: js.Promise[WriteableStream[T]]
Expand Down
4 changes: 2 additions & 2 deletions api-reports/2_13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ experimental/PointerLock.PointerLockDocument[JT] def pointerLockElement: Element
experimental/PointerLock.PointerLockElement[JT] def requestPointerLock(): Unit
experimental/PointerLock.PointerLockMouseEvent[JT] def movementX: Double
experimental/PointerLock.PointerLockMouseEvent[JT] def movementY: Double
experimental/ReadableStream[JT] def cancel(reason: String): js.Promise[Any]
experimental/ReadableStream[JT] def cancel(reason: js.UndefOr[Any] = js.undefined): js.Promise[Unit]
experimental/ReadableStream[JT] def getReader(): ReadableStreamReader[T]
experimental/ReadableStream[JT] def locked: Boolean
experimental/ReadableStream[JT] def pipeThrough[U](pair: Any, options: Any = js.undefined): ReadableStream[U]
Expand Down Expand Up @@ -469,7 +469,7 @@ experimental/WriteableState[SO] val closing = "closing".asInstanceOf[WriteableSt
experimental/WriteableState[SO] val errored = "errored".asInstanceOf[WriteableState]
experimental/WriteableState[SO] val waiting = "waiting".asInstanceOf[WriteableState]
experimental/WriteableState[SO] val writable = "writable".asInstanceOf[WriteableState]
experimental/WriteableStream[JT] def abort(reason: Any): Unit
experimental/WriteableStream[JT] def abort(reason: js.UndefOr[Any] = js.undefined): js.Promise[Unit]
experimental/WriteableStream[JT] def close(): js.Promise[WriteableStream[T]]
experimental/WriteableStream[JT] val closed: js.Promise[WriteableStream[T]]
experimental/WriteableStream[JT] val ready: js.Promise[WriteableStream[T]]
Expand Down
12 changes: 7 additions & 5 deletions src/main/scala/org/scalajs/dom/experimental/Stream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ trait WriteableStream[-T] extends js.Object {
* abort mechanism of the underlying sink.
* see [[https://streams.spec.whatwg.org/#ws-abort ¶4.2.4.4. abort(reason)]]
*
* @param reason spec specifies Any (!?)
* @param reason
*/
def abort(reason: Any): Unit = js.native
def abort(
reason: js.UndefOr[Any] = js.undefined): js.Promise[Unit] = js.native

/**
* The close method signals that the producer is done writing chunks to the
Expand Down Expand Up @@ -148,10 +149,11 @@ trait ReadableStream[+T] extends js.Object {
* the stream by a consumer. The supplied reason argument will be given to
* the underlying source, which may or may not use it.
*
* @param reason the reason <- actually not what type this is
* @return a Promise, but not quite sure what it can contain
* @param reason the reason
* @return a Promise
*/
def cancel(reason: String): js.Promise[Any] = js.native
def cancel(
reason: js.UndefOr[Any] = js.undefined): js.Promise[Unit] = js.native

/**
* See [[https://streams.spec.whatwg.org/#rs-get-reader ¶3.2.4.3. getReader()]]
Expand Down