File tree 2 files changed +19
-10
lines changed
dom/src/main/scala/org/scalajs/dom
tests-shared/src/main/scala/org/scalajs/dom/tests/shared
2 files changed +19
-10
lines changed Original file line number Diff line number Diff line change 1
1
package org .scalajs .dom
2
2
3
3
import scala .scalajs .js
4
- import scala .scalajs .js .annotation .JSGlobal
5
4
6
5
/** defined at [[https://streams.spec.whatwg.org/#readable-stream ¶2.1. Readable Streams ]] of whatwg Streams spec.
7
6
*
8
7
* @tparam T
9
8
* Type of the Chunks returned by the Stream. Can't make it coveriant, due to T
10
9
*/
11
10
@ js.native
12
- @ JSGlobal
13
- class ReadableStream [+ T ](
14
- underlyingSource : js.UndefOr [ReadableStreamUnderlyingSource [T ]],
15
- queuingStrategy : js.UndefOr [ReadableStreamQueuingStrategy [T ]] = js.undefined
16
- ) extends js.Object {
11
+ trait ReadableStream [+ T ] extends js.Object {
17
12
18
13
/** The locked getter returns whether or not the readable stream is locked to a reader.
19
14
*
@@ -97,3 +92,18 @@ class ReadableStream[+T](
97
92
*/
98
93
def tee (): js.Array [_ <: ReadableStream [T ]] = js.native // TODO js.Tuple2[ReadableStream[T], ReadableStream[T]]
99
94
}
95
+
96
+ object ReadableStream {
97
+
98
+ def apply [T ](
99
+ underlyingSource : js.UndefOr [ReadableStreamUnderlyingSource [T ]],
100
+ queuingStrategy : js.UndefOr [ReadableStreamQueuingStrategy [T ]] = js.undefined
101
+ ): ReadableStream [T ] = {
102
+ js.Dynamic
103
+ .newInstance(js.Dynamic .global.selectDynamic(" ReadableStream" ))(
104
+ underlyingSource.asInstanceOf [js.Any ],
105
+ queuingStrategy.asInstanceOf [js.Any ]
106
+ )
107
+ .asInstanceOf [ReadableStream [T ]]
108
+ }
109
+ }
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ import org.scalajs.dom.tests.shared.AsyncTesting._
7
7
import scala .concurrent .Future
8
8
import scala .scalajs .js
9
9
import scala .scalajs .js .Thenable .Implicits ._
10
- import scala .scalajs .js .|
11
10
12
11
trait SharedTests {
13
12
@@ -52,13 +51,13 @@ trait SharedTests {
52
51
Tuna (" red" )
53
52
)
54
53
55
- val stream = new ReadableStream [Tuna ](
54
+ val stream = ReadableStream [Tuna ](
56
55
new ReadableStreamUnderlyingSource [Tuna ] {
57
- start = { controller : ReadableStreamController [Tuna ] =>
56
+ start = { ( controller : ReadableStreamController [Tuna ]) =>
58
57
controller.enqueue(Tuna (" blue" ))
59
58
controller.enqueue(Tuna (" red" ))
60
59
controller.close()
61
- }. asInstanceOf [ js.UndefOr [js. Function1 [ReadableStreamController [Tuna ], Unit | js. Promise [ Unit ]]] ]
60
+ }: js.Function1 [ReadableStreamController [Tuna ], Unit ]
62
61
}
63
62
)
64
63
You can’t perform that action at this time.
0 commit comments