2024-09-10 22:37:48 -03:00
|
|
|
package sdk
|
|
|
|
|
2024-10-06 15:53:33 -03:00
|
|
|
import (
|
|
|
|
"slices"
|
2024-12-03 00:49:27 -03:00
|
|
|
|
|
|
|
jsoniter "github.com/json-iterator/go"
|
2024-10-06 15:53:33 -03:00
|
|
|
)
|
2024-09-10 22:37:48 -03:00
|
|
|
|
2024-12-03 00:49:27 -03:00
|
|
|
var json = jsoniter.ConfigFastest
|
|
|
|
|
2025-03-04 11:08:31 -03:00
|
|
|
// appendUnique adds items to an array only if they don't already exist in the array.
|
|
|
|
// Returns the modified array.
|
2024-10-06 15:53:33 -03:00
|
|
|
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
|
2024-09-25 22:38:31 -03:00
|
|
|
}
|