git.iko.soy/rowtype-yoga/purescript-parsing-dataview
on master help sign in
docs
2651a98James Brock
README.md+15−3
@@ -60,9 +60,9 @@ it depends on
60do
60do
61 result <- Text.Parsing.Parser.runParserT dataview $ do
61 result <- Text.Parsing.Parser.runParserT dataview $ do
62 -- Parse 32 bits of the big-endian 64-bit length prefix.
62 -- Parse 32 bits of the big-endian 64-bit length prefix.
63+ _ <- anyUint32be
63− _ <- anyUint32be
64+ length <- anyUint32be
64− length <- anyUint32be
65− stringview <- takeN $ UInt.toInt length
65+ stringview <- takeN $ UInt.toInt length
66 stringarray <- liftEffect $ mkTypedArray stringview
66 stringarray <- liftEffect $ mkTypedArray stringview
67 case Data.TextDecoding.decodeUtf8 stringarray of
67 case Data.TextDecoding.decodeUtf8 stringarray of
68 Left err -> Data.Parsing.Parser.fail $ show err
68 Left err -> Data.Parsing.Parser.fail $ show err
@@ -77,4 +77,16 @@ where
77 pure $ Data.ArrayBuffer.Typed.part buffer byteOffset byteLength
77 pure $ Data.ArrayBuffer.Typed.part buffer byteOffset byteLength
78```
78```
79
79
80+## Serialization
80
81
82+This package is for reading (`DataView`s on) `ArrayBuffer`s, not writing
83+them. See the package
84+[__purescript-arraybuffer-builder__](https://pursuit.purescript.org/packages/purescript-arraybuffer-builder/)
85+for a way to
86+serialize and build `ArrayBuffer`s.
87+
88+
89+## References
90+
91+* [MDN `ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
92+* [MDN `DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)
src/Text/Parsing/Parser/DataView.purs+8−11
@@ -1,22 +1,22 @@
1-- | Primitive parsers for parsing Javascript ArrayBuffers with the
1-- | Primitive parsers for parsing Javascript ArrayBuffers with the
2+-- | [`Text.Parsing.Parser`](https://pursuit.purescript.org/packages/purescript-parsing/docs/Text.Parsing.Parser)
2−-- | `Text.Parsing.Parser` module in package __purescript-parsing__.
3+-- | module in package __purescript-parsing__.
4+-- | See the package README for usage examples.
3-- |
5-- |
4-- | All of the parsers in this module operate on an input stream of
6-- | All of the parsers in this module operate on an input stream of
7+-- | [`Data.ArrayBuffer.Types.DataView`](https://pursuit.purescript.org/packages/purescript-arraybuffer-types/docs/Data.ArrayBuffer.Types#t:DataView),
5−-- | `Data.ArrayBuffer.Types.DataView`, which represents a range of an
8+-- | which represents a range of an
6-- | `Data.ArrayBuffer.Types.ArrayBuffer`.
9-- | `Data.ArrayBuffer.Types.ArrayBuffer`.
7-- |
10-- |
8-- | For operations for working with `ArrayBuffer` and `DataView`, see
11-- | For operations for working with `ArrayBuffer` and `DataView`, see
12+-- | module
13+-- | [`Data.ArrayBuffer.DataView`](https://pursuit.purescript.org/packages/purescript-arraybuffer/docs/Data.ArrayBuffer.DataView)
9−-- | module `Data.ArrayBuffer.DataView` in package __purescript-arraybuffer__.
14+-- | in package __purescript-arraybuffer__.
10-- |
15-- |
11-- | Reading from an `ArrayBuffer` is an `Effect`ful activity, so
16-- | Reading from an `ArrayBuffer` is an `Effect`ful activity, so
12-- | all parsers in this module must be run in a
17-- | all parsers in this module must be run in a
13-- | `MonadEffect m => ParserT DataView m` context, with
18-- | `MonadEffect m => ParserT DataView m` context, with
14-- | `Text.Parsing.Parser.runParserT`.
19-- | `Text.Parsing.Parser.runParserT`.
15−-- |
16−-- | ## References
17−-- |
18−-- | * [MDN `ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
19−-- | * [MDN `DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)
20module Text.Parsing.Parser.DataView
20module Text.Parsing.Parser.DataView
21 ( anyPrim
21 ( anyPrim
22 , anyInt8
22 , anyInt8
@@ -51,8 +51,6 @@ module Text.Parsing.Parser.DataView
51 , takeN
51 , takeN
52 , takeRest
52 , takeRest
53 , eof
53 , eof
54− , module Data.ArrayBuffer.Types
55− , module Data.ArrayBuffer.DataView
56 )
54 )
57 where
55 where
58
56
@@ -73,7 +71,6 @@ import Text.Parsing.Parser.Pos (Position(..))
73import Text.Parsing.Parser.Combinators (tryRethrow)
71import Text.Parsing.Parser.Combinators (tryRethrow)
74import Data.ArrayBuffer.Types
72import Data.ArrayBuffer.Types
75 ( DataView
73 ( DataView
76− , ArrayView
77 , Int16
74 , Int16
78 , Int32
75 , Int32
79 , Int8
76 , Int8