mapper

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

package mapper is collection of small mapping helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cancellable

func Cancellable[V any](n int, ctx context.Context, seq iter.Seq[V]) iter.Seq[V]

Cancellable returns an iterator over seq but it also checks if ctx is cancelled each n elements seq yields.

func Cancellable2

func Cancellable2[K, V any](n int, ctx context.Context, seq iter.Seq2[K, V]) iter.Seq2[K, V]

Cancellable2 returns an iterator over seq but it also checks if ctx is cancelled each n elements seq yields.

func Clone

func Clone[S ~[]E, E any](seq iter.Seq[S]) iter.Seq[S]

Clone maps seq by slices.Clone.

func Clone2

func Clone2[S1 ~[]E1, S2 ~[]E2, E1, E2 any](seq iter.Seq2[S1, S2]) iter.Seq2[S1, S2]

Clone2 maps seq by slices.Clone.

func Collect

func Collect[V any](seq iter.Seq[iter.Seq[V]]) iter.Seq[[]V]

Collect maps seq by slices.Collect.

func Collect2

func Collect2[K, V any](seq iter.Seq2[iter.Seq[K], iter.Seq[V]]) iter.Seq2[[]K, []V]

Collect2 maps seq by slices.Collect.

func HandleErr

func HandleErr[V any](handle func(V, error) bool, seq iter.Seq2[V, error]) iter.Seq[V]

HandleErr returns an iterator over only former value of seq. If latter value the seq yields is non-nil then it calls handle. If handle returns false the iterator stops. Even if handle returns true, values paired to non-nil error are excluded from the returned iterator.

func Sprintf

func Sprintf[V any](format string, seq iter.Seq[V]) iter.Seq[string]

Sprintf maps seq by fmt.Sprintf

func Sprintf2

func Sprintf2[K, V any](format string, seq iter.Seq2[K, V]) iter.Seq[string]

Sprintf2 maps seq by fmt.Sprintf

format receives k as fist and v as second. If callers need reversed order, callers should use %[1]verb and %[2]verb. see https://pkg.go.dev/fmt@go1.23.3#hdr-Explicit_argument_indexes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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