XUtils

purescript-parsing-dataview

Parser for deserializing ArrayBuffer


Parse two numbers

Parse two big-endian IEEE 754 double-precision Numbers.

import Parsing (runParserT)
import Parsing.DataView (anyFloat64be)

do
  result <- runParserT dataview do
    float1 <- anyFloat64be
    float2 <- anyFloat64be
    pure $ Tuple float1 float2

Parse an array

Parse an array of n 32-bit big-endian signed Ints.

import Parsing (runParserT)
import Parsing.DataView (anyUint32be)
import Data.Unfoldable (replicateA)

do
  result <- runParserT dataview $ replicateA n anyInt32be

Serialization

This package is for reading (DataViews on) ArrayBuffers, not writing them. See the package arraybuffer-builder for a way to serialize and build ArrayBuffers.

References

Development

Run the tests with the development spago file:

spago -x spago-dev.dhall test

Articles

  • coming soon...