Skip to content

Commit

Permalink
add support for typed arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Feb 3, 2025
1 parent 479e73d commit f4f6e36
Show file tree
Hide file tree
Showing 2 changed files with 481 additions and 22 deletions.
9 changes: 8 additions & 1 deletion zenoh-ts/examples/deno/src/z_bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export async function main() {
// serialization
// array
{
let input = [1, 2, 3, 5]
let input = [1, 2, 3, 4]
// by default number is serialized/deserialized as 64-bit float,
// other formats, like Int32, for example, must be specified explicitly
let payload = zserialize(input, ZS.array(ZS.number(NumberFormat.Int32)))
Expand All @@ -86,6 +86,13 @@ export async function main() {
// let output = zdeserialize(ZD.array(ZD.number()), payload)
console.log(`Input: ${input}, Output: ${output}`)
}
// typed array
{
let input = new Int32Array([1, 2, 3, 4])
let payload = zserialize(input)
let output = zdeserialize(ZD.int32array(), payload)
console.log(`Input: ${input}, Output: ${output}`)
}
// map
{
let input = new Map<bigint, string>()
Expand Down
Loading

0 comments on commit f4f6e36

Please sign in to comment.