The package inflater
provides an Inflater
interface that inflates a value
into multiple values and some operations to combine them Inflater
s.
$ go get github.com/koron-go/inflater@latest
The first idea of the inflater
was very simple: to perform an algorithm that
predicts and expands multiple strings from a single input string using a single
interface combination. Therefore, the first Inflate function was defined as
func Inflate(s string) <-chan string
Combining this with the rangefunc added in Go 1.23 and using
generics instead of string
, we have the following Inflater
interface. This
is intended to inflate multiple values based on a seed
.
type Inflater[V any] interface {
Inflate(seed V) iter.Seq[V]
}
The package inflater
provides several special Inflater
types.
None
- An Inflater that consumes all input and produces no output, like a black hole.Keep
- An Inflater that outputs the input as is.Slice
- An Inflater that ignores input and outputs all elements of the slice.Map
- An Inflater that converts input with a function and outputs it.Filter
- An Inflater that judges and filters input with a function.
It also provides the ability to combine multiple Inflater
objects to create another Inflater
object.
Parallel
- Pass the input to multipleInflater
s and concatenate their outputs into a singleiter.Seq
.Serial
- Inflate the input with the firstInflater
, inflate the output of that with the nextInflater
, and repeat that to get the output iter.Seq
In addition, we provide two Inflater
s that perform basic operations on strings.
Prefix
- An Inflater that outputs multiple values with an each prefix string attached to the input string.Suffix
- An Inflater that outputs multiple values with an each suffix string attached to the input string.