Skip to content

Commit d7886bb

Browse files
committed
Remove effect from toArray and toIntArray
1 parent 9b102a8 commit d7886bb

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

src/Data/ArrayBuffer/Typed.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,17 @@ exports.hasIndexImpl = function(a, i) {
5959
}
6060

6161
exports.toArray = function(a) {
62-
return function() {
63-
var l = a.length;
64-
var ret = new Array(l);
65-
for (var i = 0; i < l; i++)
66-
ret[i] = a[i];
67-
return ret;
68-
};
62+
var l = a.length;
63+
var ret = new Array(l);
64+
for (var i = 0; i < l; i++)
65+
ret[i] = a[i];
66+
return ret;
6967
}
7068

7169
exports.toIntArray = function(a) {
72-
return function() {
73-
var l = a.length;
74-
var ret = new Array(l);
75-
for (var i = 0; i < l; i++)
76-
ret[i] = a[i] | 0;
77-
return ret;
78-
};
70+
var l = a.length;
71+
var ret = new Array(l);
72+
for (var i = 0; i < l; i++)
73+
ret[i] = a[i] | 0;
74+
return ret;
7975
}

src/Data/ArrayBuffer/Typed.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ at a n = do
8282
pure Nothing
8383

8484
-- | Turn typed array into an array.
85-
foreign import toArray :: forall a e. ArrayView a -> Eff (arrayBuffer :: ARRAY_BUFFER | e) (Array Number)
85+
foreign import toArray :: forall a. ArrayView a -> Array Number
8686

8787
-- | Turn typed array into integer array.
88-
foreign import toIntArray :: forall a e. ArrayView a -> Eff (arrayBuffer :: ARRAY_BUFFER | e) (Array Int)
88+
foreign import toIntArray :: forall a. ArrayView a -> Array Int
8989

test/Main.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ main = do
5555
assertEffEquals Nothing $ TA.at fourElementInt8Array 4
5656
assertEffEquals Nothing $ TA.at fourElementInt8Array (-1)
5757

58-
assertEffEquals [1.0, 2.0, 3.0] $ TA.toArray <<< TA.asInt8Array <<< DV.whole $ AB.fromArray [1.0, 2.0, 3.0]
58+
assertEquals [1.0, 2.0, 3.0] $ TA.toArray <<< TA.asInt8Array <<< DV.whole $ AB.fromArray [1.0, 2.0, 3.0]
5959

6060
twoElementDataView <- do
6161
ab' <- AB.create 2

0 commit comments

Comments
 (0)