From 32df336c3e5fa174725bf95c70f5ee611c2640a9 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 22 May 2025 23:44:20 -0400 Subject: [PATCH] tape: Add DecodeVILAIter --- tape/array.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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