github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/op/delay/string_/api.go (about)

     1  // Package string_ provides string builders
     2  package string_
     3  
     4  import (
     5  	"strings"
     6  
     7  	"github.com/m4gshm/gollections/op/string_"
     8  )
     9  
    10  // Of returns string builder
    11  func Of(parts ...string) func() string {
    12  	return func() string { return strings.Join(parts, "") }
    13  }
    14  
    15  // Wrap returns wrapped string builder
    16  func Wrap(pref, post string) func(target string) string {
    17  	return func(s string) string { return pref + s + post }
    18  }
    19  
    20  // WrapNonEmpty returns wrapped string builder
    21  func WrapNonEmpty(pref, post string) func(target string) string {
    22  	return func(target string) string {
    23  		return string_.WrapNonEmpty(pref, target, post)
    24  	}
    25  }
    26  
    27  // JoinNonEmpty returns concatenated string builder
    28  func JoinNonEmpty(joiner string) func(first, second string) string {
    29  	return func(first, second string) string {
    30  		return string_.JoinNonEmpty(first, joiner, second)
    31  	}
    32  }