ltext

package module
v1.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2019 License: MIT Imports: 5 Imported by: 3

README

ltext provides a set of utilities that should simplify working with strings and texts

Install

go get github.com/belfinor/ltext

Tools

Quoted

fmt.Println(ltext.Quoted("123")) // «123»

Reverse

fmt.Println(ltext.Reverse("Hello")) // olleH
fmt.Println(ltext.Reverse("Привет, Мир!")) // !риМ ,тевирП

ReadingTime

Calculate average reading time in seconds.

txt := `В блистательном сериале «Семнадцать мгновений весны»
есть два примечательных момента, на
которые редко обращают внимание — это просто фоновые детали.
Но, тем не менее, они весьма интересны. Первая деталь. В одной
из сцен 1-й серии Штирлиц крутит настройки приёмника и находит
лёгенький джаз`

fmt.Println(ltext.ReadingTime(strings.NewReader(txt))) // 14

Truncate

If the string is longer than the specified number of runes, the string is shortened to the specified number and added to the end

fmt.Println(ltext.Truncate("Hello world!", 8)) // Hello wo…
fmt.Println(ltext.Truncate("Привет, мир!", 20)) // Привет, мир!
fmt.Println(ltext.Truncate("Привет, мир!", 9)) // Привет, м…

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNew added in v1.0.1

func AddNew(list []string, str string) []string

add value if not exists

func CmpSlices

func CmpSlices(s1 []string, s2 []string) bool

func IsSpace

func IsSpace(run rune) bool

func Proc

func Proc(in io.Reader, fn StrFunc)

func Quoted

func Quoted(text string) string

func ReadingTime added in v1.0.9

func ReadingTime(in io.Reader) int

func Reverse added in v1.0.8

func Reverse(text string) string

func Stream

func Stream(in io.Reader, fn StrConvFunc, chanSize int) <-chan string

func Truncate

func Truncate(text string, limit int) string

func WordsOnly added in v1.0.5

func WordsOnly(in io.Reader) string

Types

type StrConvFunc

type StrConvFunc func(string) string

type StrFunc

type StrFunc func(string)

Directories

Path Synopsis
encoding

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL