// Wrap wraps an io.Writer into a writer that flushes after every write if
// the writer implements the Flusher interface.
428319
func Wrap(w io.Writer) io.Writer {
	fw := &flushWriter{
		writer: w,
	}
	if flusher, ok := w.(http.Flusher); ok {
		fw.flusher = flusher
	}
	return fw
}
909751
func (w *WrapWriter) Write(p []byte) (n int, err error) {
	n, err = Wrap(w, p, w.off, w.wrapAt)
	w.off = (w.off + int64(n)) % w.wrapAt
	return n, err
}
447970
func (s *Selection) Wrap(selector string) *Selection {
	return s.WrapMatcher(compileMatcher(selector))
}
1293368
func (m *Module) wrap(h Handle) httprouter.Handle {
	return func(rw http.ResponseWriter, req *http.Request, par Params) {
		err := h(rw, req, par)
		if err != nil && m.ErrorHandler != nil {
			m.ErrorHandler(rw, req, err)
		}
	}
}
694778
func (s *WriterSender) Close() error {
	s.mu.Lock()
	defer s.mu.Unlock()

	if err := s.writer.Flush(); err != nil {
		return err
	}

	s.Send(message.NewBytesMessage(s.priority, bytes.TrimRightFunc(s.buffer.Bytes(), unicode.IsSpace)))
	s.buffer.Reset()
	s.writer.Reset(s.buffer)
	return nil
}
757739
func (logger *RequestLogger) Wrap(innerconnection plugin.Connection) plugin.Connection {
	logger.connection = innerconnection
	return logger
}
100734
func (c *ContextWrapper) Wrap(ctx context.Context) context.Context {
	return metadata.NewOutgoingContext(ctx, c.md)
}
522085
func (w *Writer) Close() error {
	if w.BeforeClose != nil {
		w.BeforeClose()
	}

	if closer, ok := w.Writer.(io.Closer); ok {
		err := closer.Close()
		if err != nil {
			return err
		}
	}

	if w.AfterClose != nil {
		w.AfterClose()
	}

	return nil
}
1040398
func Wrap(l net.Listener, m mode) *T {
	t := &T{
		l:    l,
		mode: m,
		// To keep the expected contention rate constant we'd have to
		// grow this as numcpu**2. In practice, CPU counts don't
		// generally grow without bound, and contention is probably
		// going to be small enough that nobody cares anyways.
		shards: make([]shard, 2*runtime.NumCPU()),
	}
	for i := range t.shards {
		t.shards[i].init(t)
	}
	return t
}
25609
func (fw *flushWriter) Write(p []byte) (n int, err error) {
	n, err = fw.writer.Write(p)
	if err != nil {
		return
	}
	if fw.flusher != nil {
		fw.flusher.Flush()
	}
	return
}
469313
func (logger *RequestLogger) Wrap(innerconnection uaa.Connection) uaa.Connection {
	logger.connection = innerconnection
	return logger
}
1103717
func Wrap(handler http.Handler) Handler {
	return HandlerFunc(func(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
		handler.ServeHTTP(rw, r)
		next(rw, r)
	})
}
179955
func Wrap(child ds.Datastore, prefix ds.Key) *ktds.Datastore {
	if child == nil {
		panic("child (ds.Datastore) is nil")
	}

	return ktds.Wrap(child, PrefixTransform(prefix))
}
1353619
func Wrap(err error, message string) error {
	if err == nil {
		return nil
	}
	err = &withMessage{
		cause: err,
		msg:   message,
	}
	return &withStack{
		err,
		callers(),
	}
}
995944
func (w *Writer) Flush() error {
	if _, err := w.w.Write(w.b); err != nil {
		return err
	}
	w.b = w.b[:0]
	return nil
}
962485
func Wrap(err error, message string) error {
	if err == nil {
		return nil
	}
	return &wrapping{
		cause: err,
		msg:   message,
		stack: callers(),
	}
}
191448
func (m *BucketRequestCounter) Wrap(next http.Handler) http.Handler {
	f := func(w http.ResponseWriter, r *http.Request) {
		m.ServeHTTP(w, r, next)
	}
	return http.HandlerFunc(f)
}