File tree 3 files changed +13
-1
lines changed
3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 14
14
},
15
15
"dependencies" : {
16
16
"purescript-eff" : " ^3.0.0" ,
17
- "purescript-maybe" : " ^3.0.0"
17
+ "purescript-maybe" : " ^3.0.0" ,
18
+ "purescript-arraybuffer-types" : " ^2.0.0"
18
19
},
19
20
"devDependencies" : {
20
21
"purescript-assert" : " ^3.0.0" ,
Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ exports.fromStringImpl = function (str) {
25
25
} ;
26
26
} ;
27
27
28
+ exports . toArrayBuffer = function ( buff ) {
29
+ return function ( ) {
30
+ return buff . buffer . slice ( buff . byteOffset , buff . byteOffset + buff . byteLength ) ;
31
+ } ;
32
+ } ;
33
+
28
34
exports . readImpl = function ( ty ) {
29
35
return function ( offset ) {
30
36
return function ( buf ) {
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ module Node.Buffer
7
7
, create
8
8
, fromArray
9
9
, fromString
10
+ , toArrayBuffer
10
11
, read
11
12
, readString
12
13
, toString
@@ -23,7 +24,9 @@ module Node.Buffer
23
24
) where
24
25
25
26
import Prelude
27
+
26
28
import Control.Monad.Eff (Eff , kind Effect )
29
+ import Data.ArrayBuffer.Types (ArrayBuffer )
27
30
import Data.Maybe (Maybe (..))
28
31
import Node.Encoding (Encoding , encodingToNode )
29
32
@@ -91,6 +94,8 @@ fromString str = fromStringImpl str <<< encodingToNode
91
94
92
95
foreign import fromStringImpl :: forall e . String -> String -> Eff (buffer :: BUFFER | e ) Buffer
93
96
97
+ foreign import toArrayBuffer :: forall e . Buffer -> Eff (buffer :: BUFFER | e ) ArrayBuffer
98
+
94
99
-- | Reads a numeric value from a buffer at the specified offset.
95
100
read :: forall e . BufferValueType -> Offset -> Buffer -> Eff (buffer :: BUFFER | e ) Int
96
101
read = readImpl <<< show
You can’t perform that action at this time.
0 commit comments