1- [ ** sync-op** ] ( ../README.md ) • ** Docs **
1+ [ ** sync-op** ] ( ../README.md )
22
33***
44
55[ sync-op] ( ../README.md ) / Channel
66
77# Class: Channel\< T\>
88
9+ Defined in: [ channel.ts:23] ( https://github.com/dhcmrlchtdj/sync-op/blob/93fe32636f3c6c188a811dfea276951b3e31f9bc/src/channel.ts#L23 )
10+
911the synchronous channel
1012
1113## Type Parameters
1214
13- • ** T**
15+ ### T
16+
17+ ` T `
1418
1519## Implements
1620
@@ -19,9 +23,11 @@ the synchronous channel
1923
2024## Constructors
2125
22- ### new Channel()
26+ ### Constructor
2327
24- > ** new Channel** \< ` T ` \> (` capacity ` ): [ ` Channel ` ] ( Channel.md ) \< ` T ` \>
28+ > ** new Channel** \< ` T ` \> (` capacity ` ): ` Channel ` \< ` T ` \>
29+
30+ Defined in: [ channel.ts:38] ( https://github.com/dhcmrlchtdj/sync-op/blob/93fe32636f3c6c188a811dfea276951b3e31f9bc/src/channel.ts#L38 )
2531
2632create a new channel with buffer size ` capacity `
2733
@@ -32,22 +38,22 @@ const buffered = new Channel(1)
3238
3339#### Parameters
3440
35- • ** capacity** : ` number ` = ` 0 `
41+ ##### capacity
3642
37- #### Returns
43+ ` number ` = ` 0 `
3844
39- [ ` Channel ` ] ( Channel.md ) \< ` T ` \>
40-
41- #### Defined in
45+ #### Returns
4246
43- [ channel.ts:38 ] ( https://github.com/dhcmrlchtdj/sync-op/blob/163328e6c4e45f4e1851de6e0cd2086a60714f03/src/channel.ts#L38 )
47+ ` Channel ` \< ` T ` \>
4448
4549## Methods
4650
4751### \[ asyncIterator\] ()
4852
4953> ** \[ asyncIterator\] ** (): ` AsyncGenerator ` \< ` Awaited ` \< ` T ` \> , ` void ` , ` unknown ` \>
5054
55+ Defined in: [ channel.ts:182] ( https://github.com/dhcmrlchtdj/sync-op/blob/93fe32636f3c6c188a811dfea276951b3e31f9bc/src/channel.ts#L182 )
56+
5157``` typescript
5258const ch = new Channel ()
5359ch .send (1 )
@@ -63,18 +69,16 @@ for await (const msg of ch) {
6369
6470#### Implementation of
6571
66- [ ` readableChannel ` ] ( ../interfaces/readableChannel.md ) .[ ` [asyncIterator] ` ] ( ../interfaces/readableChannel.md#%5Basynciterator%5D )
67-
68- #### Defined in
69-
70- [ channel.ts:182] ( https://github.com/dhcmrlchtdj/sync-op/blob/163328e6c4e45f4e1851de6e0cd2086a60714f03/src/channel.ts#L182 )
72+ [ ` readableChannel ` ] ( ../interfaces/readableChannel.md ) .[ ` [asyncIterator] ` ] ( ../interfaces/readableChannel.md#asynciterator )
7173
7274***
7375
7476### close()
7577
7678> ** close** (): ` void `
7779
80+ Defined in: [ channel.ts:52] ( https://github.com/dhcmrlchtdj/sync-op/blob/93fe32636f3c6c188a811dfea276951b3e31f9bc/src/channel.ts#L52 )
81+
7882#### Returns
7983
8084` void `
@@ -83,16 +87,14 @@ for await (const msg of ch) {
8387
8488[ ` writableChannel ` ] ( ../interfaces/writableChannel.md ) .[ ` close ` ] ( ../interfaces/writableChannel.md#close )
8589
86- #### Defined in
87-
88- [ channel.ts:52] ( https://github.com/dhcmrlchtdj/sync-op/blob/163328e6c4e45f4e1851de6e0cd2086a60714f03/src/channel.ts#L52 )
89-
9090***
9191
9292### isClosed()
9393
9494> ** isClosed** (): ` boolean `
9595
96+ Defined in: [ channel.ts:64] ( https://github.com/dhcmrlchtdj/sync-op/blob/93fe32636f3c6c188a811dfea276951b3e31f9bc/src/channel.ts#L64 )
97+
9698#### Returns
9799
98100` boolean `
@@ -101,16 +103,14 @@ for await (const msg of ch) {
101103
102104[ ` writableChannel ` ] ( ../interfaces/writableChannel.md ) .[ ` isClosed ` ] ( ../interfaces/writableChannel.md#isclosed )
103105
104- #### Defined in
105-
106- [ channel.ts:64] ( https://github.com/dhcmrlchtdj/sync-op/blob/163328e6c4e45f4e1851de6e0cd2086a60714f03/src/channel.ts#L64 )
107-
108106***
109107
110108### isDrained()
111109
112110> ** isDrained** (): ` boolean `
113111
112+ Defined in: [ channel.ts:71] ( https://github.com/dhcmrlchtdj/sync-op/blob/93fe32636f3c6c188a811dfea276951b3e31f9bc/src/channel.ts#L71 )
113+
114114returns ` true ` if the buffer is empty and there are no pending senders.
115115
116116#### Returns
@@ -121,16 +121,14 @@ returns `true` if the buffer is empty and there are no pending senders.
121121
122122[ ` writableChannel ` ] ( ../interfaces/writableChannel.md ) .[ ` isDrained ` ] ( ../interfaces/writableChannel.md#isdrained )
123123
124- #### Defined in
125-
126- [ channel.ts:71] ( https://github.com/dhcmrlchtdj/sync-op/blob/163328e6c4e45f4e1851de6e0cd2086a60714f03/src/channel.ts#L71 )
127-
128124***
129125
130126### receive()
131127
132128> ** receive** (): [ ` Op ` ] ( Op.md ) \< [ ` Option ` ] ( ../type-aliases/Option.md ) \< ` T ` \>\>
133129
130+ Defined in: [ channel.ts:132] ( https://github.com/dhcmrlchtdj/sync-op/blob/93fe32636f3c6c188a811dfea276951b3e31f9bc/src/channel.ts#L132 )
131+
134132receives a message from the channel.
135133if the channel is drained, return ` none ` .
136134
@@ -147,16 +145,14 @@ const msg = await op.sync()
147145
148146[ ` readableChannel ` ] ( ../interfaces/readableChannel.md ) .[ ` receive ` ] ( ../interfaces/readableChannel.md#receive )
149147
150- #### Defined in
151-
152- [ channel.ts:132] ( https://github.com/dhcmrlchtdj/sync-op/blob/163328e6c4e45f4e1851de6e0cd2086a60714f03/src/channel.ts#L132 )
153-
154148***
155149
156150### send()
157151
158152> ** send** (` data ` ): [ ` Op ` ] ( Op.md ) \< ` boolean ` \>
159153
154+ Defined in: [ channel.ts:88] ( https://github.com/dhcmrlchtdj/sync-op/blob/93fe32636f3c6c188a811dfea276951b3e31f9bc/src/channel.ts#L88 )
155+
160156sends the ` data ` message to the channel.
161157if channel is closed, return ` false ` .
162158
@@ -167,7 +163,9 @@ await op.sync()
167163
168164#### Parameters
169165
170- • ** data** : ` T `
166+ ##### data
167+
168+ ` T `
171169
172170#### Returns
173171
@@ -176,7 +174,3 @@ await op.sync()
176174#### Implementation of
177175
178176[ ` writableChannel ` ] ( ../interfaces/writableChannel.md ) .[ ` send ` ] ( ../interfaces/writableChannel.md#send )
179-
180- #### Defined in
181-
182- [ channel.ts:88] ( https://github.com/dhcmrlchtdj/sync-op/blob/163328e6c4e45f4e1851de6e0cd2086a60714f03/src/channel.ts#L88 )
0 commit comments