MCPcopy Create free account
hub / github.com/astercloud/aster / Map

Function Map

pkg/stream/stream.go:616–620  ·  view source on GitHub ↗

Map 对流中的每个值应用函数

(r *Reader[T], fn func(T) U)

Source from the content-addressed store, hash-verified

614
615// Map 对流中的每个值应用函数
616func Map[T, U any](r *Reader[T], fn func(T) U) *Reader[U] {
617 return TransformSimple(r, func(v T) (U, error) {
618 return fn(v), nil
619 })
620}
621
622// Take 返回只产出前 n 个值的读取器
623func Take[T any](r *Reader[T], n int) *Reader[T] {

Callers 1

TestMapFunction · 0.85

Calls 1

TransformSimpleFunction · 0.85

Tested by 1

TestMapFunction · 0.68