diff --git a/tape/array.go b/tape/array.go index 00cdffb..04265d2 100644 --- a/tape/array.go +++ b/tape/array.go @@ -69,6 +69,19 @@ func DecodeVILA(data []byte) ArrayPullFunc { } } +// DecodeVILAIter decodes a variable item length array and returns it as an +// iterator. +func DecodeVILAIter(data []byte) iter.Seq[[]byte] { + return func(yield func([]byte) bool) { + pull := DecodeVILA(data) + for { + value, _, err := pull() + if err != nil { return } + if !yield(value) { return } + } + } +} + // EncodeVILA encodes a variable item length array. func EncodeVILA(data []byte, items ...[]byte) ArrayPushFunc { n := 0