Skip to content

Commit 355f17e

Browse files
committed
toString' -> join, changed args order
1 parent ea63698 commit 355f17e

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/Data/ArrayBuffer/Typed.purs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module Data.ArrayBuffer.Typed
1818
, foldlM, foldl1M, foldl, foldl1, foldrM, foldr1M, foldr, foldr1
1919
, find, findIndex, indexOf, lastIndexOf
2020
, slice, subArray
21-
, toString, toString', toArray
21+
, toString, join, toArray
2222
) where
2323

2424
import Data.Array (length) as A
@@ -126,7 +126,7 @@ type Length = Int
126126
-- | - `indexOf` and `lastIndexOf` are searching functions via equality
127127
-- | - `slice` returns a new typed array on the same array buffer content as the input
128128
-- | - `subArray` returns a new typed array with a separate array buffer
129-
-- | - `toString` prints to a CSV, `toString'` allows you to supply the delimiter
129+
-- | - `toString` prints to a CSV, `join` allows you to supply the delimiter
130130
-- | - `toArray` returns an array of numeric values
131131
class BinaryValue a t <= TypedArray (a :: ArrayViewType) (t :: Type) | a -> t where
132132
create :: forall x. EffectFn3 x (Nullable ByteOffset) (Nullable ByteLength) (ArrayView a)
@@ -388,18 +388,19 @@ toString a = runEffectFn1 toStringImpl a
388388
foreign import joinImpl :: forall a. EffectFn2 (ArrayView a) String String
389389

390390
-- | Prints array to a delimiter-separated string - see [MDN's spec](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/join) for details.
391-
toString' :: forall a. ArrayView a -> String -> Effect String
392-
toString' a s = runEffectFn2 joinImpl a s
391+
join :: forall a. String -> ArrayView a -> Effect String
392+
join s a = runEffectFn2 joinImpl a s
393393

394394

395-
foreign import unsafeAtImpl :: forall a b. EffectFn2 (ArrayView a) Offset b
396-
397395
foreign import hasIndexImpl :: forall a. Fn2 (ArrayView a) Offset Boolean
398396

399397
-- | Determine if a certain index is valid.
400398
hasIndex :: forall a. ArrayView a -> Offset -> Boolean
401399
hasIndex a o = runFn2 hasIndexImpl a o
402400

401+
402+
foreign import unsafeAtImpl :: forall a b. EffectFn2 (ArrayView a) Offset b
403+
403404
-- | Fetch element at index.
404405
at :: forall a t. TypedArray a t => ArrayView a -> Offset -> Effect (Maybe t)
405406
at a n = if a `hasIndex` n

test/Properties/TypedArray.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ typedArrayTests count = do
7777
sortIsIdempotentTests count
7878
log " - toArray (sort x) == Array.sort (toArray x)"
7979
sortIsArraySortTests count
80-
log " - toString' \",\" x == toString x"
80+
log " - join \",\" x == toString x"
8181
toStringIsJoinWithCommaTests count
8282
log " - setTyped x (subArray x) == x"
8383
setTypedOfSubArrayIsIdentityTests count
@@ -467,7 +467,7 @@ toStringIsJoinWithCommaTests count = overAll count toStringIsJoinWithComma
467467
where
468468
toStringIsJoinWithComma :: forall a b t. TestableArrayF a b D0 t Result
469469
toStringIsJoinWithComma (WithOffset _ xs) = do
470-
s1 <- TA.toString' xs ","
470+
s1 <- TA.join "," xs
471471
s2 <- TA.toString xs
472472
pure $ s1 === s2
473473

0 commit comments

Comments
 (0)