// NewChecksummedWriter returns a ChecksummedWriter that delegates requests to
// an underlying io.Writer and embeds checksums of the content at given
// intervals using the hashing function given.
337574
func NewChecksummedWriter(delegate io.Writer, checksumInterval int, newHash func() hash.Hash32) ChecksummedWriter {
	return newChecksummedWriterImpl(delegate, checksumInterval, newHash)
}
795424
func AddCheckSum(content string) (string, error) {
	if content == "" {
		return "", errors.New("content is empty")
	}

	even := len(content)%2 == 1
	sum := 0
	for _, r := range content {
		if _, ok := encodingTable[r]; ok {
			value := utils.RuneToInt(r)
			if even {
				sum += value * 3
			} else {
				sum += value
			}
			even = !even
		} else {
			return "", fmt.Errorf("can not encode \"%s\"", content)
		}
	}

	return content + string(utils.IntToRune(sum%10)), nil
}
1280235
func NewWriter(w io.Writer, bo binary.ByteOrder) Writer {
	return &writer{
		w:  w,
		bo: bo,
	}
}
184171
func NewCompressWriter(w io.Writer) *compressWriter {
	p := &compressWriter{writer: w}
	p.data = make([]byte, BlockMaxSize, BlockMaxSize)

	zlen := lz4.CompressBound(BlockMaxSize) + HeaderSize
	p.zdata = make([]byte, zlen, zlen)
	return p
}
317658
func (f *fragment) Checksum() []byte {
	h := xxhash.New()
	for _, block := range f.Blocks() {
		_, _ = h.Write(block.Checksum)
	}
	return h.Sum(nil)
}
529152
func (b *block) ComputeChecksum() (unsigned, signed int64) {
	for i, c := range b {
		if 148 <= i && i < 156 {
			c = ' ' // Treat the checksum field itself as all spaces.
		}
		unsigned += int64(c)
		signed += int64(int8(c))
	}
	return unsigned, signed
}
21272
func NewWriter(w io.Writer) *Writer {
	if wr, ok := w.(*Writer); ok {
		return wr
	}
	return &Writer{
		w:   w,
		buf: make([]byte, 0, DefaultWriterSize),
	}
}
1182420
func NewWriter(w io.Writer, width int, flag uint) *Writer {
	return &Writer{
		w:     w,
		width: width,
		flag:  flag,
	}
}
410054
func NewContentChecker(content Content, sizeTracker SizeTracker, checksumWriter ChecksumWriter) *Checker {
	return &Checker{
		Content:        content,
		SizeTracker:    sizeTracker,
		ChecksumWriter: checksumWriter,
	}
}
621222
func NewWriter(writer io.WriteSeeker, hash func([]byte) uint32) (*Writer, error) {
	// Leave 256 * 8 bytes for the index at the head of the file.
	_, err := writer.Seek(0, os.SEEK_SET)
	if err != nil {
		return nil, err
	}

	_, err = writer.Write(make([]byte, indexSize))
	if err != nil {
		return nil, err
	}

	if hash == nil {
		hash = cdbHash
	}

	return &Writer{
		hash:           hash,
		writer:         writer,
		bufferedWriter: bufio.NewWriterSize(writer, 65536),
		bufferedOffset: indexSize,
	}, nil
}
1210725
func NewChecker(config *Config) *Checker {
	if config == nil {
		config = &Config{}
	}

	if config.RuntimeTTL == 0 {
		config.RuntimeTTL = DefaultRuntimeTTL
	}

	return &Checker{
		since:      time.Now(),
		metadata:   make(map[string]interface{}),
		checks:     make(map[string]*check),
		runtimeTTL: config.RuntimeTTL,
	}
}
1273420
func NewWriter(w io.Writer) (io.Writer, error) {
	tr, err := toCp949()
	if err != nil {
		return nil, err
	}

	return &cp949Writer{w: w, tr: tr}, nil
}
369682
func NewCheckedBytesPool(
	sizes []Bucket,
	opts ObjectPoolOptions,
	newBackingBytesPool NewBytesPoolFn,
) CheckedBytesPool {
	return &checkedBytesPool{
		bytesPool: newBackingBytesPool(sizes),
		pool:      NewBucketizedObjectPool(sizes, opts),
	}
}
1320344
func newCheckCommand(m *Main) *CheckCommand {
	return &CheckCommand{
		Stdin:  m.Stdin,
		Stdout: m.Stdout,
		Stderr: m.Stderr,
	}
}
318399
func NewWriterLevelDict(w io.Writer, level int, dict []byte) (*Writer, error) {
	if level < HuffmanOnly || level > BestCompression {
		return nil, fmt.Errorf("zlib: invalid compression level: %d", level)
	}
	return &Writer{
		w:     w,
		level: level,
		dict:  dict,
	}, nil
}
30048
func NewWriteFlusher(w io.Writer) *WriteFlusher {
	var fl flusher
	if f, ok := w.(flusher); ok {
		fl = f
	} else {
		fl = &NopFlusher{}
	}
	return &WriteFlusher{w: w, flusher: fl, closed: make(chan struct{}), flushed: make(chan struct{})}
}
79926
func NewLeveledWriter(standard io.Writer, overrides map[Level]io.Writer) *LeveledWriter {
	return &LeveledWriter{
		standard:  standard,
		overrides: overrides,
	}
}