args,meta: add a Len()

This commit is contained in:
Michael Muré
2024-12-12 16:06:01 +01:00
parent 042d6dc52f
commit 416345dba9
4 changed files with 18 additions and 0 deletions

View File

@@ -92,6 +92,11 @@ func (a *Args) Include(other Iterator) {
}
}
// Len return the number of arguments.
func (a *Args) Len() int {
return len(a.Keys)
}
// Iter iterates over the args key/values
func (a *Args) Iter() iter.Seq2[string, ipld.Node] {
return func(yield func(string, ipld.Node) bool) {

View File

@@ -14,6 +14,10 @@ func (r ReadOnly) GetNode(key string) (ipld.Node, error) {
return r.args.GetNode(key)
}
func (r ReadOnly) Len() int {
return r.args.Len()
}
func (r ReadOnly) Iter() iter.Seq2[string, ipld.Node] {
return r.args.Iter()
}