about summary refs log tree commit diff stats
path: root/src/io/readablestream.nim
blob: 8269f1dcf85797c248c8424fe2d2c8bb08a230f8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#TODO....

type
  UnderlyingSourceStartCallback = proc(controller: ReadableStreamController):
    Option[JSValue] # may be undefined!
  UnderlyingSourcePullCallback = proc(controller: ReadableStreamController):
    EmptyPromise
  UnderlyingSourceCancelCallback = proc(reason = none(JSValue)): EmptyPromise

  ReadableStreamType = enum
    BYOB = "byob"

  UnderlyingSource* = object
    start*: Option[UnderlyingSourceStartCallback]
    pull*: Option[UnderlyingSourcePullCallback]
    cancel*: Option[UnderlyingSourcePullCallback]
    #TODO mark real name being type
    ctype*: Option[ReadableStreamType]

  QueuingStrategySize = proc(chunk: JSValue): float64 # unrestricted

  QueuingStrategy* = object
    highWaterMark*: float64 # unrestricted
    size*: QueuingStrategySize

  ReadableStream* = object
    underlyingSource: UnderlyingSource

proc newReadableStream(underlyingSource = none(UnderlyingSource);
    strategy = none(QueuingStrategySize)): ReadableStream =
  let this = ReadableStream()
  discard