async write(value) {
    if (this.closed) {
      throw new ClosedChannelError();
    }

    if (this.reads.length > 0) {
      const read = this.reads.splice(0, 1)[0];
      read.res(value);
      return null;
    }

    if (this.data.length >= this.maxBuffered) {
      return new Promise((resolve, reject) => {
        this.writes.push({
          val: value,
          res: resolve,
          rej: reject
        });
      });
    }

    this.data.push(value);
    return null;
  }
/**
   * Writes a value on the channel. Returns a promise that is resolved when the written value has written to the channel's buffer
   * @param {any} value - Value to write to channel
   */
Writes a value on the channel. Returns a promise that is resolved when the written value has written to the channel's buffer
@param {any} value - Value to write to channel
Writes a value on the channel . Returns a promise that is resolved when the written value has written to the channel ' s buffer @param { any } value - Value to write to channel
async write(value) {
    if (this.closed) {
      throw new ClosedChannelError();
    }
    if (this.reads.length > 0) {
      const read = this.reads.splice(0, 1)[0];
      read.res(value);
      return null;
    }
    if (this.data.length >= this.maxBuffered) {
      return new Promise((resolve, reject) => {
        this.writes.push({
          val: value,
          res: resolve,
          rej: reject
        });
      });
    }
    this.data.push(value);
    return null;
  }
async write ( value ) { if ( this . closed ) { throw new ClosedChannelError ( ) ; } if ( this . reads . length > 0 ) { const read = this . reads . splice ( 0 , 1 ) [ 0 ] ; read . res ( value ) ; return null ; } if ( this . data . length >= this . maxBuffered ) { return new Promise ( ( resolve , reject ) => { this . writes . push ( { val : value , res : resolve , rej : reject } ) ; } ) ; } this . data . push ( value ) ; return null ; }
Writes a value on the channel.
Writes a value on the channel .