BinaryFormat.List

Last updated 5 months ago

BinaryFormat.List

Returns a binary format that reads a sequence of items and returns a list.

function (binaryFormat as function, optional countOrCondition as nullable any) as function

Description

Returns a binary format that reads a sequence of items and returns a list. The binaryFormat parameter specifies the binary format of each item. There are three ways to determine the number of items read:

Category

Binary Formats.Reading lists

Examples

Read bytes until the end of the data.

let
binaryData = #binary({1, 2, 3}),
listFormat = BinaryFormat.List(BinaryFormat.Byte)
in
listFormat(binaryData)

{1, 2, 3}

Read two bytes.

let
binaryData = #binary({1, 2, 3}),
listFormat = BinaryFormat.List(BinaryFormat.Byte, 2)
in
listFormat(binaryData)

{1, 2}

Read bytes until the byte value is greater than or equal to two.

let
binaryData = #binary({1, 2, 3}),
listFormat = BinaryFormat.List(BinaryFormat.Byte, (x) => x < 2)
in
listFormat(binaryData)

{1, 2}