Skip to content

Commit f35d6c6

Browse files
committed
toIntArray
1 parent a8992c7 commit f35d6c6

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Data/ArrayBuffer/Typed.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,11 @@ exports.toArray = function(a) {
6363
ret[i] = a[i];
6464
return ret;
6565
}
66+
67+
exports.toIntArray = function(a) {
68+
var l = a.length;
69+
var ret = new Array(l);
70+
for (var i = 0; i < l; i++)
71+
ret[i] = a[i]|0;
72+
return ret;
73+
}

src/Data/ArrayBuffer/Typed.purs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module Data.ArrayBuffer.Typed( Writer()
1414
, hasIndex
1515
, at
1616
, toArray
17+
, toIntArray
1718
) where
1819

1920
import Prelude (Unit, ($))
@@ -82,3 +83,7 @@ at a n = if a `hasIndex` n then
8283

8384
-- | Turn typed array into an array.
8485
foreign import toArray :: forall a. ArrayView a -> Array Number
86+
87+
-- | Turn typed array into integer array.
88+
foreign import toIntArray :: forall a. ArrayView a -> Array Int
89+

0 commit comments

Comments
 (0)