diff --git a/pkg/args/args.go b/pkg/args/args.go index a840c6e..305b9af 100644 --- a/pkg/args/args.go +++ b/pkg/args/args.go @@ -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) { diff --git a/pkg/args/readonly.go b/pkg/args/readonly.go index 62c6587..0e4e44f 100644 --- a/pkg/args/readonly.go +++ b/pkg/args/readonly.go @@ -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() } diff --git a/pkg/meta/meta.go b/pkg/meta/meta.go index bf12815..9273bbc 100644 --- a/pkg/meta/meta.go +++ b/pkg/meta/meta.go @@ -192,6 +192,11 @@ func (m *Meta) Include(other Iterator) { } } +// Len returns the number of key/values. +func (m *Meta) Len() int { + return len(m.Values) +} + // Iter iterates over the meta key/values func (m *Meta) Iter() iter.Seq2[string, ipld.Node] { return func(yield func(string, ipld.Node) bool) { diff --git a/pkg/meta/readonly.go b/pkg/meta/readonly.go index 26d667d..4e6ddfb 100644 --- a/pkg/meta/readonly.go +++ b/pkg/meta/readonly.go @@ -43,6 +43,10 @@ func (r ReadOnly) GetNode(key string) (ipld.Node, error) { return r.meta.GetNode(key) } +func (r ReadOnly) Len() int { + return r.meta.Len() +} + func (r ReadOnly) Iter() iter.Seq2[string, ipld.Node] { return r.meta.Iter() }