Skip to content

Commit 825ed85

Browse files
committed
make AsyncSeq.mapi public
1 parent 9df32a2 commit 825ed85

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/FSharp.Control.AsyncSeq/AsyncSeq.fsi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,13 @@ module AsyncSeq =
321321
/// be asked for the next element after the processing of an element completes).
322322
val mapiAsync : mapping:(int64 -> 'T -> Async<'U>) -> source:AsyncSeq<'T> -> AsyncSeq<'U>
323323

324+
/// Builds a new asynchronous sequence whose elements are generated by
325+
/// applying the specified function to all elements of the input sequence.
326+
///
327+
/// The specified function is synchronous (and the input sequence will
328+
/// be asked for the next element after the processing of an element completes).
329+
val mapi : mapping:(int64 -> 'T -> 'U) -> source:AsyncSeq<'T> -> AsyncSeq<'U>
330+
324331
[<System.Obsolete("Renamed to mapiAsync") >]
325332
val zipWithIndexAsync : mapping:(int64 -> 'T -> Async<'U>) -> source:AsyncSeq<'T> -> AsyncSeq<'U>
326333

tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,20 @@ let ``AsyncSeq.unfoldAsync should be iterable in finite resources``() =
13781378

13791379

13801380

1381+
[<Test>]
1382+
let ``AsyncSeq.mapi should work`` () =
1383+
for i in 0..100 do
1384+
let ls = List.init i (fun x -> x + 100)
1385+
let expected =
1386+
ls
1387+
|> List.mapi (fun i x -> sprintf "%i_%i" i x)
1388+
let actual =
1389+
ls
1390+
|> AsyncSeq.ofSeq
1391+
|> AsyncSeq.mapi (fun i x -> sprintf "%i_%i" i x)
1392+
|> AsyncSeq.toList
1393+
Assert.AreEqual(expected, actual)
1394+
13811395

13821396
[<Test>]
13831397
let ``AsyncSeq.take should work``() =

0 commit comments

Comments
 (0)