File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 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) {
2525 } ;
2626} ;
2727
28+ exports . fromArrayBuffer = function ( ab ) {
29+ return function ( ) {
30+ return Buffer . from ( ab ) ;
31+ } ;
32+ } ;
33+
2834exports . toArrayBuffer = function ( buff ) {
2935 return function ( ) {
3036 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
77 , create
88 , fromArray
99 , fromString
10+ , fromArrayBuffer
1011 , toArrayBuffer
1112 , read
1213 , readString
@@ -87,6 +88,11 @@ foreign import create :: forall e. Int -> Eff (buffer :: BUFFER | e) Buffer
8788-- | Creates a new buffer from an array of octets, sized to match the array.
8889foreign import fromArray :: forall e . Array Octet -> Eff (buffer :: BUFFER | e ) Buffer
8990
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+
9096-- | Creates a new buffer from a string with the specified encoding, sized to
9197-- | match the string.
9298fromString :: forall e . String -> Encoding -> Eff (buffer :: BUFFER | e ) Buffer
You can’t perform that action at this time.
0 commit comments