function arrayWhile
arrayWhile<TDecoded>(
elementType: Coder<TDecoded>,
): Coder<TDecoded[]>

Creates a Coder for arrays using a custom condition function to determine when to stop.

This is the most flexible array coder that can handle any termination logic. The condition function has access to the current state and can implement complex logic like null termination, conditional arrays, or custom termination conditions.

Note: For length-prefixed arrays, use arrayLP. For fixed-length arrays, use arrayFL. This function is best suited for custom termination logic that doesn't fit the standard patterns.

Type Parameters

TDecoded

Parameters

elementType: Coder<TDecoded>

The coder for individual array elements

Function that determines when to continue processing

Return Type

A Coder that can encode/decode arrays using the custom condition

Usage

import { arrayWhile } from "mod.ts";