batch

tiny golang package for pagination-style batching of slices
Log | Files | Refs | README | LICENSE

README.md (712B)


      1 # batch
      2 
      3 import "github.com/markhuge/batch"
      4 
      5 Package batch provides helper functions for batching slices into sub slices of a
      6 specified length. You could think of it as pagination for slices.
      7 
      8 ## Usage
      9 
     10 #### func  Str
     11 
     12 ```go
     13 func Str(s []string, pageSize int) [][]string
     14 ```
     15 Str accepts a slice of strings and a page size, then splits up the slice into
     16 smaller slices of length "pageSize"
     17 
     18 #### func  StrJoin
     19 
     20 ```go
     21 func StrJoin(s []string, pageSize int, delimiter string) []string
     22 ```
     23 StrJoin is a combination of Str() and strings.Join(). Rather than returning a
     24 slice of slices, it returns a slice of joined strings
     25 
     26 
     27 ## Tests
     28 
     29 ```
     30 PASS
     31 coverage: 100.0% of statements
     32 ok  	github.com/markhuge/batch	1.007s
     33 ```