Skip to content
This repository was archived by the owner on Jan 26, 2022. It is now read-only.

Commit d5bd93c

Browse files
authored
Always await first arg to pipeAsync
Fixes #4.
1 parent 6daa265 commit d5bd93c

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

README.md

+10-9
Original file line numberDiff line numberDiff line change
@@ -149,25 +149,26 @@ The promise will resolve to the final sub-function’s result.
149149
```js
150150
Function.pipeAsync(input, ...fns);
151151

152-
// Resolves to ((await (await fetch(url, options)).json()) + 1) * 2.
153-
await Function.pipeAsync(url,
152+
// A promise that will resolve to ((await (await fetch(await url, options)).json()) + 1) * 2.
153+
Function.pipeAsync(url,
154154
x => fetch(x, options),
155155
x => x.json(),
156156
x => x + 1,
157157
x => x * 2,
158158
);
159159

160-
// Resolves to 5.
161-
await Function.pipeAsync(5);
160+
// A promise that will resolve to 5.
161+
Function.pipeAsync(5);
162162

163-
// Resolves to undefined.
164-
await Function.pipeAsync();
163+
// A promise that will resolve to undefined.
164+
Function.pipeAsync();
165165

166-
// Rejects with a SyntaxError.
167-
await Function.pipeAsync('x', JSON.parse);
166+
// A promise that will reject with a SyntaxError.
167+
Function.pipeAsync('x', JSON.parse);
168168
```
169169

170-
The first sub-function is applied to `input` and then `await`ed,
170+
The input is first `await`ed.
171+
Then the first sub-function is applied to `input` and then `await`ed,
171172
then the second sub-function is applied to the first sub-function’s result then `await`ed,
172173
and so forth.
173174
In other words, function piping occurs from left to right.

0 commit comments

Comments
 (0)