github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/pipes/term/err_js.go (about)

     1  //go:build js
     2  // +build js
     3  
     4  package term
     5  
     6  import (
     7  	"github.com/lmorg/murex/lang/stdio"
     8  	"github.com/lmorg/murex/utils"
     9  )
    10  
    11  // Terminal: Standard Error
    12  
    13  // Err is the Stderr interface for term
    14  type Err struct {
    15  	term
    16  }
    17  
    18  // SetDataType is a null method because the term interface is write-only
    19  func (t *Err) SetDataType(string) {}
    20  
    21  // Write is the io.Writer() interface for term
    22  func (t *Err) Write(b []byte) (int, error) {
    23  	t.mutex.Lock()
    24  	t.bWritten += uint64(len(b))
    25  	t.mutex.Unlock()
    26  
    27  	vtermWrite([]rune(string(b)))
    28  
    29  	return len(b), nil
    30  }
    31  
    32  // Writeln writes an OS-specific terminated line to the stderr
    33  func (t *Err) Writeln(b []byte) (int, error) {
    34  	return t.Write(appendBytes(b, utils.NewLineByte...))
    35  }
    36  
    37  // WriteArray performs data type specific buffered writes to an stdio.Io interface
    38  func (t *Err) WriteArray(dataType string) (stdio.ArrayWriter, error) {
    39  	return stdio.WriteArray(t, dataType)
    40  }