mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-05-07 01:00:19 +02:00
22 lines
410 B
Go
22 lines
410 B
Go
package sdk
|
|
|
|
import (
|
|
"slices"
|
|
|
|
jsoniter "github.com/json-iterator/go"
|
|
)
|
|
|
|
var json = jsoniter.ConfigFastest
|
|
|
|
// appendUnique adds items to an array only if they don't already exist in the array.
|
|
// Returns the modified array.
|
|
func appendUnique[I comparable](arr []I, item ...I) []I {
|
|
for _, item := range item {
|
|
if slices.Contains(arr, item) {
|
|
return arr
|
|
}
|
|
arr = append(arr, item)
|
|
}
|
|
return arr
|
|
}
|