Skip to content

Commit

Permalink
implement v1 PackageList.ToMap
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen3H committed Apr 23, 2024
1 parent 98cb9d6 commit 37ae1e9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions v1/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"strings"

"github.com/samber/lo"
"github.com/the-egg-corp/thundergo/util"
)

Expand Down Expand Up @@ -49,6 +50,12 @@ func (original *PackageList) AddFlat(list PackageList) {
*original = append(*original, list...)
}

func (original *PackageList) ToMap() map[string]Package {
return lo.Associate(*original, func(pkg Package) (string, Package) {
return pkg.UUID, pkg
})
}

// Grab a single package from the list given the package owner's name and the package's short name.
func (list PackageList) Get(author string, name string) *Package {
return util.TryFind(list, func(p Package) bool {
Expand Down

0 comments on commit 37ae1e9

Please sign in to comment.