mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-01 02:51:37 +02:00
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:
13
lnutils/stream.go
Normal file
13
lnutils/stream.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user