multi: add lnutils to host fundamental utility functions

We also move the `fn/stream.go` into the package `lnutils`. Eventually
we will put all the [utility
functions](https://github.com/lightninglabs/taro/tree/main/chanutils)
into this package.
This commit is contained in:
yyforyongyu
2023-01-19 06:31:17 +08:00
parent 48c8c1bf48
commit 89b0e25e2c
3 changed files with 7 additions and 3 deletions

13
lnutils/stream.go Normal file
View File

@ -0,0 +1,13 @@
package lnutils
// Map takes an input slice, and applies the function f to each element,
// yielding a new slice.
func Map[T1, T2 any](s []T1, f func(T1) T2) []T2 {
r := make([]T2, len(s))
for i, v := range s {
r[i] = f(v)
}
return r
}