ofDelayedFunc further improved
This commit is contained in:
parent
08e28c8c1a
commit
d5afefc540
2
of.go
2
of.go
@ -20,13 +20,13 @@ func OfDelayedFunc[T any](delayFunc func(value T) time.Duration, values ...T) <-
|
||||
out := make(chan T, len(values))
|
||||
|
||||
go func(out chan T, values []T) {
|
||||
defer close(out)
|
||||
for i, value := range values {
|
||||
out <- value
|
||||
if i < len(values)-1 {
|
||||
time.Sleep(delayFunc(value))
|
||||
}
|
||||
}
|
||||
close(out)
|
||||
}(out, values)
|
||||
|
||||
return out
|
||||
|
Loading…
Reference in New Issue
Block a user