git.iko.soy/rowtype-yoga/purescript-parsing-dataview
on master help sign in
docs
commit2651a98fe2a323c70659c1dd31f60fc29b3f70b9 authorJames Brock <jamesbrock@gmail.com> dateMon 27 Jul 2020, 23:45 (6 years ago) parent0922629
2 files changed+23−14
README.md+15−3 src/Text/Parsing/Parser/DataView.purs+8−11
README.md+15−3
@@ -60,9 +60,9 @@ it depends on
6060do
6161 result <- Text.Parsing.Parser.runParserT dataview $ do
6262 -- Parse 32 bits of the big-endian 64-bit length prefix.
63− _ <- anyUint32be
64− length <- anyUint32be
65− stringview <- takeN $ UInt.toInt length
63+ _ <- anyUint32be
64+ length <- anyUint32be
65+ stringview <- takeN $ UInt.toInt length
6666 stringarray <- liftEffect $ mkTypedArray stringview
6767 case Data.TextDecoding.decodeUtf8 stringarray of
6868 Left err -> Data.Parsing.Parser.fail $ show err
@@ -77,4 +77,16 @@ where
7777 pure $ Data.ArrayBuffer.Typed.part buffer byteOffset byteLength
7878```
7979
80+## Serialization
8081
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 @@
11-- | Primitive parsers for parsing Javascript ArrayBuffers with the
2−-- | `Text.Parsing.Parser` module in package __purescript-parsing__.
2+-- | [`Text.Parsing.Parser`](https://pursuit.purescript.org/packages/purescript-parsing/docs/Text.Parsing.Parser)
3+-- | module in package __purescript-parsing__.
4+-- | See the package README for usage examples.
35-- |
46-- | All of the parsers in this module operate on an input stream of
5−-- | `Data.ArrayBuffer.Types.DataView`, which represents a range of an
7+-- | [`Data.ArrayBuffer.Types.DataView`](https://pursuit.purescript.org/packages/purescript-arraybuffer-types/docs/Data.ArrayBuffer.Types#t:DataView),
8+-- | which represents a range of an
69-- | `Data.ArrayBuffer.Types.ArrayBuffer`.
710-- |
811-- | For operations for working with `ArrayBuffer` and `DataView`, see
9−-- | module `Data.ArrayBuffer.DataView` in package __purescript-arraybuffer__.
12+-- | module
13+-- | [`Data.ArrayBuffer.DataView`](https://pursuit.purescript.org/packages/purescript-arraybuffer/docs/Data.ArrayBuffer.DataView)
14+-- | in package __purescript-arraybuffer__.
1015-- |
1116-- | Reading from an `ArrayBuffer` is an `Effect`ful activity, so
1217-- | all parsers in this module must be run in a
1318-- | `MonadEffect m => ParserT DataView m` context, with
1419-- | `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)
2020module Text.Parsing.Parser.DataView
2121 ( anyPrim
2222 , anyInt8
@@ -51,8 +51,6 @@ module Text.Parsing.Parser.DataView
5151 , takeN
5252 , takeRest
5353 , eof
54− , module Data.ArrayBuffer.Types
55− , module Data.ArrayBuffer.DataView
5654 )
5755 where
5856
@@ -73,7 +71,6 @@ import Text.Parsing.Parser.Pos (Position(..))
7371import Text.Parsing.Parser.Combinators (tryRethrow)
7472import Data.ArrayBuffer.Types
7573 ( DataView
76− , ArrayView
7774 , Int16
7875 , Int32
7976 , Int8