//OutputBytes to  RWI.writer ([]byte data).
171255
func (c *RWI) OutputBytes(data []byte) error {
	return c.WriteFrom(bytes.NewReader(data))
}
152978
func (stream *Stream) writeByte(c byte) {
	stream.buf = append(stream.buf, c)
}
896095
func (enc *Encoder) writeBytes(p []byte) {
	enc.buf = append(enc.buf, p...)
}
699668
func (c *Websocket) WriteBytesBinary(b []byte) *Websocket {
	if c.checkUnusable("WriteBytesBinary") {
		return c
	}
	return c.WriteMessage(websocket.BinaryMessage, b)
}
1305082
func (out *RAMOutputStream) WriteToBytes(bytes []byte) error {
	err := out.Flush()
	if err != nil {
		return err
	}
	end := out.file.length
	pos := int64(0)
	buffer := 0
	bytesUpto := 0
	for pos < end {
		length := BUFFER_SIZE
		nextPos := pos + int64(length)
		if nextPos > end {
			length = int(end - pos)
		}
		copy(bytes[bytesUpto:], out.file.Buffer(buffer)[:length])
		buffer++
		bytesUpto += length
		pos = nextPos
	}
	return nil
}
1013290
func (mw *Writer) Write(buf []byte) (int, error) {
	if mw.err != nil {
		return 0, mw.err
	}

	var wrCnt int
	for _, b := range buf {
		zeros, ones := numBits(b)

		// If possible, avoid flushing to maintain high efficiency.
		if ensured := mw.bufCnt < EnsureRawBytes; ensured {
			goto skipEncode
		}
		if huffLen, _ := mw.computeHuffLen(mw.buf0s+zeros, mw.buf1s+ones); huffLen > 0 {
			goto skipEncode
		}

		mw.err = mw.encodeBlock(FinalNil)
		if mw.err != nil {
			break
		}

	skipEncode:
		mw.buf0s += zeros
		mw.buf1s += ones
		mw.buf[mw.bufCnt] = b
		mw.bufCnt++
		wrCnt++
	}

	mw.InputOffset += int64(wrCnt)
	return wrCnt, mw.err
}
3373
func (b *Builder) WriteByte(c byte) error {
	b.lastRead = opInvalid
	m := b.grow(1)
	b.buf[m] = c
	return nil
}
206406
func Write(w io.Writer, message io.Reader, order binary.ByteOrder) (i int, err error) {
	data, err := ioutil.ReadAll(message)
	if err != nil {
		return 0, err
	}

	header := make([]byte, messageSizeInBytes)
	order.PutUint32(header, uint32(len(data)))
	return w.Write(append(header, data...))
}
821343
func formatOutput(data interface{}, format string) ([]byte, error) {
	var out string

	switch format {

	case "json":
		jsonout, err := json.MarshalIndent(data, "", "  ")
		if err != nil {
			return nil, err
		}
		out = string(jsonout)

	case "text":
		out = data.(fmt.Stringer).String()

	default:
		return nil, fmt.Errorf("Invalid output format \"%s\"", format)

	}
	return []byte(prepareOutput(out)), nil
}
1274501
func ioOutputFormatMessage(ld *LineData, b *bytes.Buffer) error {
	_, err := b.WriteString(ld.Message)
	return err
}
557622
func Uint32Bytes(v uint32) []byte {
	b := make([]byte, 4)
	PutUint32(b, v)
	return b
}
327375
func JSONBytes(w http.ResponseWriter, status int, b []byte) (err error) {

	w.Header().Set(ContentType, ApplicationJSONCharsetUTF8)
	w.WriteHeader(status)
	_, err = w.Write(b)
	return
}
734529
func (out *RAMOutputStream) WriteByte(b byte) error {
	if out.bufferPosition == out.bufferLength {
		out.currentBufferIndex++
		out.switchCurrentBuffer()
	}
	if out.crc != nil {
		out.crc.Write([]byte{b})
	}
	out.currentBuffer[out.bufferPosition] = b
	out.bufferPosition++
	return nil
}
388183
func asByteArray(blob []byte) string {
	out := &bytes.Buffer{}
	fmt.Fprintf(out, "[]byte{")
	for i := 0; i < len(blob); i++ {
		fmt.Fprintf(out, "%d, ", blob[i])
		if i%14 == 1 {
			fmt.Fprintln(out)
		}
	}
	fmt.Fprintf(out, "}")
	return out.String()
}
412723
func (c *i2cConnection) WriteByteData(reg uint8, val uint8) (err error) {
	c.mutex.Lock()
	defer c.mutex.Unlock()

	if err := c.bus.SetAddress(c.address); err != nil {
		return err
	}
	return c.bus.WriteByteData(reg, val)
}
1175149
func formatBytes(i int64) (result string) {
	switch {
	case i >= TiB:
		result = fmt.Sprintf("%.02f TiB", float64(i)/TiB)
	case i >= GiB:
		result = fmt.Sprintf("%.02f GiB", float64(i)/GiB)
	case i >= MiB:
		result = fmt.Sprintf("%.02f MiB", float64(i)/MiB)
	case i >= KiB:
		result = fmt.Sprintf("%.02f KiB", float64(i)/KiB)
	default:
		result = fmt.Sprintf("%d B", i)
	}
	return
}
1023498
func (s *stream) readBytes(n uint32) ([]byte, error) {
	if n > s.size {
		s.buf = make([]byte, n)
		s.size = n
	}

	if _, err := io.ReadFull(s.Reader, s.buf[:n]); err != nil {
		return nil, err
	}

	return s.buf[:n], nil
}