diff --git a/v1/api.go b/v1/api.go index d3685b7..54d5281 100644 --- a/v1/api.go +++ b/v1/api.go @@ -7,20 +7,21 @@ import ( "golang.org/x/sync/errgroup" ) -// // The list of every package on Thunderstore across every community. -// func GetAllPackages() (PackageList, error) { -// communities, err := Exp.GetCommunities() +func PackagesFromCommunity(identifier string) (PackageList, error) { + comm := Community{ + Identifier: identifier, + } -// if err != nil { -// return nil, err -// } + return comm.AllPackages() +} -// identifiers := lop.Map(communities, func(c Exp.Community, _ int) string { -// return c.Identifier -// }) +func PackageFromCommunity(identifier string, owner string, packageName string) *Package { + comm := Community{ + Identifier: identifier, + } -// return PackagesFromCommunities(NewCommunityList(identifiers...)) -// } + return comm.GetPackage(owner, packageName) +} // Returns a single slice with all packages from the specified communities. func PackagesFromCommunities(communities []Community) (PackageList, error) { diff --git a/v1/community.go b/v1/community.go index 07b073c..efb2d4c 100644 --- a/v1/community.go +++ b/v1/community.go @@ -34,7 +34,7 @@ func (comm Community) AllPackages(predicate ...func(item Package, index int) boo } // Gets a single package from this community given the owner and package name. -func (comm Community) GetPackage(author string, name string) *Package { +func (comm Community) GetPackage(owner string, name string) *Package { // if pkgCache != nil { // return pkgCache.Get(author, name) // } @@ -45,5 +45,5 @@ func (comm Community) GetPackage(author string, name string) *Package { return nil } - return pkgs.Get(author, name) + return pkgs.Get(owner, name) } diff --git a/v1/package.go b/v1/package.go index b8235e3..62042e7 100644 --- a/v1/package.go +++ b/v1/package.go @@ -57,9 +57,9 @@ func (original *PackageList) ToMap() map[string]Package { } // 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 { +func (list PackageList) Get(owner string, name string) *Package { return util.TryFind(list, func(p Package) bool { - return strings.EqualFold(p.Name, name) && strings.EqualFold(p.Owner, author) + return strings.EqualFold(p.Name, name) && strings.EqualFold(p.Owner, owner) }) }