File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed 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 . fromArrayBuffer = function ( ab ) {
29
+ return function ( ) {
30
+ return Buffer . from ( ab ) ;
31
+ } ;
32
+ } ;
33
+
28
34
exports . toArrayBuffer = function ( buff ) {
29
35
return function ( ) {
30
36
return buff . buffer . slice ( buff . byteOffset , buff . byteOffset + buff . byteLength ) ;
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
+ , fromArrayBuffer
10
11
, toArrayBuffer
11
12
, read
12
13
, readString
@@ -87,6 +88,11 @@ foreign import create :: forall e. Int -> Eff (buffer :: BUFFER | e) Buffer
87
88
-- | Creates a new buffer from an array of octets, sized to match the array.
88
89
foreign import fromArray :: forall e . Array Octet -> Eff (buffer :: BUFFER | e ) Buffer
89
90
91
+ -- | Creates a buffer view from a JS ArrayByffer without copying data.
92
+ --
93
+ -- Requires Node >= v5.10.0
94
+ foreign import fromArrayBuffer :: forall e . ArrayBuffer -> Eff (buffer :: BUFFER | e ) Buffer
95
+
90
96
-- | Creates a new buffer from a string with the specified encoding, sized to
91
97
-- | match the string.
92
98
fromString :: forall e . String -> Encoding -> Eff (buffer :: BUFFER | e ) Buffer
You can’t perform that action at this time.
0 commit comments