From facec4c0ff521bbc9d5b3fde771a34001664716f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=C2=A0S=2E=C2=A0Choi?= Date: Tue, 12 Jul 2022 01:27:09 -0400 Subject: [PATCH] =?UTF-8?q?Revert=20#20=20and=20do=20not=20await=20async?= =?UTF-8?q?=20inputs=E2=80=99=20values=20without=20mapping=20=C6=92=20(#27?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 14 +++++++++----- spec.html | 7 +++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 243118e..84bc4c8 100644 --- a/README.md +++ b/README.md @@ -219,11 +219,15 @@ const d = await Data.fromAsync(asyncGen(4)); ### Optional parameters Array.fromAsync has two optional parameters: `mapfn` and `thisArg`. -`mapfn` is a mapping callback, which is called on each value yielded from the -input (and awaited if it came from a synchronous input), along with its index -integer (starting from 0). Each result of the mapping callback is, in turn, -awaited then added to the array. By default, the callback is essentially an -identity function. +`mapfn` is an optional mapping callback, which is called on each value yielded +from the input (and awaited if it came from a synchronous input), along with +its index integer (starting from 0). Each result of the mapping callback is, in +turn, awaited then added to the array. + +(Without the optional mapping callback, each value yielded from asynchronous +inputs is not awaited, and each value yielded from synchronous inputs is +awaited only once, before the value is added to the result array. This matches +the behavior of `for await`.) `thisArg` is a `this`-binding receiver value for the mapping callback. By default, this is undefined. These optional parameters match the behavior of diff --git a/spec.html b/spec.html index d3d98b2..a1ab64b 100644 --- a/spec.html +++ b/spec.html @@ -144,11 +144,10 @@

Array.fromAsync ( _asyncItems_ [ , _mapfn_ [ , _thisArg_ ] ] )