@@ -27,35 +27,25 @@ import Control.Monad.Eff
2727import Data.Maybe
2828import Node.Encoding
2929
30- -- |
31- -- Type synonym indicating the value should be an octet (0-255). If the value
32- -- provided is outside this range it will be used as modulo 255.
33- --
30+ -- | Type synonym indicating the value should be an octet (0-255). If the value
31+ -- | provided is outside this range it will be used as modulo 255.
3432type Octet = Int
3533
36- -- |
37- -- Type synonym indicating the value refers to an offset in a buffer.
38- --
34+ -- | Type synonym indicating the value refers to an offset in a buffer.
3935type Offset = Int
4036
41- -- |
42- -- An instance of Node's Buffer class.
43- --
37+ -- | An instance of Node's Buffer class.
4438foreign import data Buffer :: *
4539
4640instance showBuffer :: Show Buffer where
4741 show = showImpl
48-
42+
4943foreign import showImpl :: Buffer -> String
5044
51- -- |
52- -- Effect for buffer modification.
53- --
45+ -- | Effect for buffer modification.
5446foreign import data BufferWrite :: !
5547
56- -- |
57- -- Enumeration of the numeric types that can be written to a buffer.
58- --
48+ -- | Enumeration of the numeric types that can be written to a buffer.
5949data BufferValueType
6050 = UInt8
6151 | UInt16LE
@@ -88,113 +78,81 @@ instance showBufferValueType :: Show BufferValueType where
8878 show DoubleLE = " DoubleLE"
8979 show DoubleBE = " DoubleBE"
9080
91- -- |
92- -- Creates a new buffer of the specified size.
93- --
81+ -- | Creates a new buffer of the specified size.
9482foreign import create :: Int -> Buffer
9583
96- -- |
97- -- Creates a new buffer from an array of octets, sized to match the array.
98- --
84+ -- | Creates a new buffer from an array of octets, sized to match the array.
9985foreign import fromArray :: Array Octet -> Buffer
10086
101- -- |
102- -- Creates a new buffer from a string with the specified encoding, sized to
103- -- match the string.
104- --
87+ -- | Creates a new buffer from a string with the specified encoding, sized to
88+ -- | match the string.
10589fromString :: String -> Encoding -> Buffer
10690fromString str = fromStringImpl str <<< show
10791
10892foreign import fromStringImpl :: String -> String -> Buffer
10993
110- -- |
111- -- Reads a numeric value from a buffer at the specified offset.
112- --
94+ -- | Reads a numeric value from a buffer at the specified offset.
11395read :: BufferValueType -> Offset -> Buffer -> Int
11496read = readImpl <<< show
11597
11698foreign import readImpl :: String -> Offset -> Buffer -> Int
11799
118- -- |
119- -- Reads a section of a buffer as a string with the specified encoding.
120- --
100+ -- | Reads a section of a buffer as a string with the specified encoding.
121101readString :: Encoding -> Offset -> Offset -> Buffer -> String
122102readString = readStringImpl <<< show
123103
124104foreign import readStringImpl :: String -> Offset -> Offset -> Buffer -> String
125-
126- -- |
127- -- Reads the buffer as a string with the specified encoding.
128- --
105+
106+ -- | Reads the buffer as a string with the specified encoding.
129107toString :: Encoding -> Buffer -> String
130108toString = toStringImpl <<< show
131109
132110foreign import toStringImpl :: String -> Buffer -> String
133111
134- -- |
135- -- Writes a numeric value to a buffer at the specified offset.
136- --
112+ -- | Writes a numeric value to a buffer at the specified offset.
137113write :: forall e . BufferValueType -> Int -> Offset -> Buffer -> Eff (buffer :: BufferWrite | e ) Unit
138114write = writeImpl <<< show
139115
140116foreign import writeImpl ::
141117 forall e . String -> Int -> Offset -> Buffer -> Eff (buffer :: BufferWrite | e ) Unit
142118
143- -- |
144- -- Writes octets from a string to a buffer at the specified offset. Multi-byte
145- -- characters will not be written to the buffer if there is not enough capacity
146- -- to write them fully. The number of bytes written is returned.
147- --
119+ -- | Writes octets from a string to a buffer at the specified offset. Multi-byte
120+ -- | characters will not be written to the buffer if there is not enough capacity
121+ -- | to write them fully. The number of bytes written is returned.
148122writeString :: forall e . Encoding -> Offset -> Int -> String -> Buffer -> Eff (buffer :: BufferWrite | e ) Int
149123writeString = writeStringImpl <<< show
150124
151125foreign import writeStringImpl ::
152126 forall e . String -> Offset -> Int -> String -> Buffer -> Eff (buffer :: BufferWrite | e ) Int
153127
154- -- |
155- -- Creates an array of octets from a buffer's contents.
156- --
128+ -- | Creates an array of octets from a buffer's contents.
157129foreign import toArray :: Buffer -> Array Octet
158130
159- -- |
160- -- Reads an octet from a buffer at the specified offset.
161- --
131+ -- | Reads an octet from a buffer at the specified offset.
162132getAtOffset :: Offset -> Buffer -> Maybe Octet
163133getAtOffset = getAtOffsetImpl Just Nothing
164134
165135foreign import getAtOffsetImpl ::
166136 (Octet -> Maybe Octet ) -> Maybe Octet -> Offset -> Buffer -> Maybe Octet
167137
168- -- |
169- -- Writes an octet in the buffer at the specified offset.
170- --
138+ -- | Writes an octet in the buffer at the specified offset.
171139foreign import setAtOffset ::
172140 forall e . Octet -> Offset -> Buffer -> Eff (buffer :: BufferWrite | e ) Unit
173141
174- -- |
175- -- Returns the size of a buffer.
176- --
142+ -- | Returns the size of a buffer.
177143foreign import size :: Buffer -> Int
178144
179- -- |
180- -- Concatenates a list of buffers.
181- --
145+ -- | Concatenates a list of buffers.
182146foreign import concat :: Array Buffer -> Buffer
183-
184- -- |
185- -- Concatenates a list of buffers, combining them into a new buffer of the
186- -- specified length.
187- --
147+
148+ -- | Concatenates a list of buffers, combining them into a new buffer of the
149+ -- | specified length.
188150foreign import concat' :: Array Buffer -> Int -> Buffer
189151
190- -- |
191- -- Copies a section of a source buffer into a target buffer at the specified
192- -- offset.
193- --
152+ -- | Copies a section of a source buffer into a target buffer at the specified
153+ -- | offset.
194154foreign import copy :: Offset -> Offset -> Buffer -> Offset -> Buffer -> Buffer
195-
196- -- |
197- -- Fills a range in a buffer with the specified octet.
198- --
155+
156+ -- | Fills a range in a buffer with the specified octet.
199157foreign import fill ::
200158 forall e . Octet -> Offset -> Offset -> Buffer -> Eff (buffer :: BufferWrite | e ) Unit
0 commit comments