File tree Expand file tree Collapse file tree 3 files changed +13
-1
lines changed
Expand file tree Collapse file tree 3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 1414 },
1515 "dependencies": {
1616 "purescript-eff": "^3.0.0",
17- "purescript-maybe": "^3.0.0"
17+ "purescript-maybe": "^3.0.0",
18+ "purescript-arraybuffer-types": "^2.0.0"
1819 },
1920 "devDependencies": {
2021 "purescript-assert": "^3.0.0",
Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ exports.fromStringImpl = function (str) {
2525 };
2626};
2727
28+ exports.toArrayBuffer = function(buff) {
29+ return function() {
30+ return buff.buffer.slice(buff.byteOffset, buff.byteOffset + buff.byteLength);
31+ };
32+ };
33+
2834exports.readImpl = function (ty) {
2935 return function (offset) {
3036 return function (buf) {
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ module Node.Buffer
77 , create
88 , fromArray
99 , fromString
10+ , toArrayBuffer
1011 , read
1112 , readString
1213 , toString
@@ -23,7 +24,9 @@ module Node.Buffer
2324 ) where
2425
2526import Prelude
27+
2628import Control.Monad.Eff (Eff, kind Effect)
29+ import Data.ArrayBuffer.Types (ArrayBuffer)
2730import Data.Maybe (Maybe(..))
2831import Node.Encoding (Encoding, encodingToNode)
2932
@@ -91,6 +94,8 @@ fromString str = fromStringImpl str <<< encodingToNode
9194
9295foreign import fromStringImpl :: forall e. String -> String -> Eff (buffer :: BUFFER | e) Buffer
9396
97+ foreign import toArrayBuffer :: forall e. Buffer -> Eff (buffer :: BUFFER | e) ArrayBuffer
98+
9499-- | Reads a numeric value from a buffer at the specified offset.
95100read :: forall e. BufferValueType -> Offset -> Buffer -> Eff (buffer :: BUFFER | e) Int
96101read = readImpl <<< show
You can’t perform that action at this time.
0 commit comments