Skip to content

Commit a609638

Browse files
committed
Fix , closes #19
1 parent 5715c16 commit a609638

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/Data/ArrayBuffer/DataView.purs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ module Data.ArrayBuffer.DataView( whole
3636
) where
3737

3838
import Prelude
39-
--import Data.ArrayBuffer.ArrayBuffer (ARRAY_BUFFER)
4039
import Data.ArrayBuffer.Types (ByteOffset, DataView, ByteLength, ArrayBuffer)
4140
import Data.Function.Uncurried (Fn5, Fn7, runFn5, runFn7)
4241
import Data.Maybe (Maybe(..))

src/Data/ArrayBuffer/Typed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ exports.asFloat64Array = function(v) {
3939
}
4040

4141
exports.dataView = function(a) {
42-
return a;
42+
return new DataView(a.buffer);
4343
}
4444

4545
exports.setImpl = function(ra, off, a) {

test/Main.purs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,12 @@ main = do
8585
DV.setUint8 dv t 2
8686
DV.setUint8 dv t 3
8787
DV.getUint32be dv 0
88+
89+
let arr = DV.whole (AB.fromIntArray [0x4, 0x3, 0x2, 0x1])
90+
91+
assertEffEquals (Just 0x04) (DV.getInt8 arr 0)
92+
assertEffEquals (Just 0x04) (DV.getInt8 (TA.dataView (TA.asInt8Array arr)) 0)
93+
assertEffEquals (Just 0x0304) (DV.getInt16le arr 0)
94+
assertEffEquals (Just 0x0304) (DV.getInt16le (TA.dataView (TA.asInt16Array arr)) 0)
95+
assertEffEquals (Just 0x01020304) (DV.getInt32le arr 0)
96+
assertEffEquals (Just 0x01020304) (DV.getInt32le (TA.dataView (TA.asInt32Array arr)) 0)

0 commit comments

Comments
 (0)