// Trim returns a formatter that trims leading and trailing whitespace from
// the input formatter.
17881
func Trim(formatter Formatter) Formatter {
	return func(buffer Buffer, event *cue.Event) {
		tmp := GetBuffer()
		defer ReleaseBuffer(tmp)

		formatter(tmp, event)
		buffer.AppendString(strings.TrimSpace(string(tmp.Bytes())))
	}
}
873179
func Truncate(formatter Formatter, length int) Formatter {
	return func(buffer Buffer, event *cue.Event) {
		tmp := GetBuffer()
		defer ReleaseBuffer(tmp)

		formatter(tmp, event)
		bytes := tmp.Bytes()
		if len(bytes) > length {
			bytes = bytes[:length]
		}
		buffer.Append(bytes)
	}
}
416298
func trimSpaces(k AST) AST {
	// trim left hand side of spaces
	for i := 0; i < len(k.Root.raw); i++ {
		if !isWhitespace(k.Root.raw[i]) {
			break
		}

		k.Root.raw = k.Root.raw[1:]
		i--
	}

	// trim right hand side of spaces
	for i := len(k.Root.raw) - 1; i >= 0; i-- {
		if !isWhitespace(k.Root.raw[i]) {
			break
		}

		k.Root.raw = k.Root.raw[:len(k.Root.raw)-1]
	}

	return k
}
1167978
func TrimSpaceSlice(a []string) []string {
	other := make([]string, 0, len(a))
	for _, s := range a {
		s = strings.TrimSpace(s)
		if s == "" {
			continue
		}
		other = append(other, s)
	}
	return other
}
1085994
func trimEnds(val string, max int) string {
	if utf8.RuneCountInString(val) <= max {
		return val
	}
	trimlen := utf8.RuneCountInString(Trimend)
	if trimlen < max {
		return val[:max-trimlen] + Trimend
	}
	return Trimend[:max]
}
48193
func trimPath(filename string) string {
	for _, prefix := range trimPaths {
		if trimmed := strings.TrimPrefix(filename, prefix); len(trimmed) < len(filename) {
			return trimmed
		}
	}
	return filename
}
163551
func (l *Lexer) Remainder() (string, bool) {
	l.SkipWhiteSpaces()
	if r := l.Peek(); r == ';' {
		l.Next()
	}
	l.SkipWhiteSpaces()
	if l.pos >= len(l.input) {
		return "", false
	}
	input := l.input[l.pos:]
	if len(input) < 5 {
		return "", false
	}
	return input, true
}
67319
func TrimSentenceLength(sentenceInput string, maxLength int) string {
	if len(sentenceInput) <= maxLength {
		return sentenceInput
	}
	sentenceLen := string(sentenceInput[0:maxLength]) // first350 := string(s[0:350])
	rx_end := regexp.MustCompile(`[[:punct:]][^[[:punct:]]]*$`)
	sentencePunct := rx_end.ReplaceAllString(sentenceLen, "")
	if len(sentencePunct) >= 2 {
		return sentencePunct
	}
	return sentenceLen
}
149057
func (m *MultiFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field) {
	m.mutex.RLock()
	for i := range m.formatters {
		m.formatters[i].Format(w, entry, fields)
	}
	m.mutex.RUnlock()
}
222185
func (s ShortFuncFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field) {
	f := runtime.FuncForPC(entry.Caller.PC)
	if f == nil {
		fmt.Fprintf(w, s.FormatVerb, "(unknown)")
		return
	}

	fname := f.Name()
	funcIdx := strings.LastIndex(fname, ".")
	fmt.Fprintf(w, s.FormatVerb, fname[funcIdx+1:])
}
348978
func trimTrailingSeparator(hostURL string) string {
	separator := string(newClientURL(hostURL).Separator)
	return strings.TrimSuffix(hostURL, separator)
}
908536
func Trim(str, chars string) string {
	return LeftTrim(RightTrim(str, chars), chars)
}
447327
func trimHash(l string) string {
	if strings.Contains(l, "#") {
		var index int
		for n, str := range l {
			if strconv.QuoteRune(str) == "'#'" {
				index = n
				break
			}
		}
		return l[:index]
	}
	return l
}
620496
func trimCut(label []byte, maxlen int, left, right string) []byte {
	trim := bytes.TrimLeft(label, left)
	size := min(len(trim), maxlen)
	head := bytes.TrimRight(trim[:size], right)
	if len(head) == size {
		return head
	}
	tail := bytes.TrimLeft(trim[size:], right)
	if len(tail) > 0 {
		return append(head, tail[:min(len(tail), size-len(head))]...)
	}
	return head
}
816204
func format(s string, codes interface{}) string {
	var seq string

	switch v := codes.(type) {

	case string:
		seq = v
	case []int:
		seq = makeSequence(v)
	default:
		return s
	}

	if len(seq) == 0 {
		return s
	}
	return startFormat(seq) + s + stopFormat()
}
217078
func (f Formatter) Indent(indent int) *Formatter {
	f.IndentLevel = f.IndentLevel + indent
	return &f
}
1044720
func TrimLinesInString(input string) string {
	return strings.Join(TrimLines(strings.Split(strings.TrimSpace(input), "\n")), "\n")
}