You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Time passes, a new requirement comes in: now you have to query a database for custom colors. This is an async operation, so naturally you convert `getColorByName` into async function.
40
+
Time passes, a new requirement emerges: now you have to query a database for custom colors. This is an async operation, so naturally you convert `getColorByName` into async function.
41
41
42
42
Turns out it has a cost: now all the code above should also be async. You try this:
43
43
@@ -68,11 +68,9 @@ Yay!
68
68
API is
69
69
[String.prototype.replace()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace), except the first argument is a string itself.
Runs `replaceValue` and waits for it to resolve before replacing `searchValue`
74
-
with results. If `searchValue` is a _global_ RegExp, `replaceValue` will be
75
-
called concurrently for every match.
73
+
Runs `replace` and waits for it to resolve before replacing `searchValue` with results. If `searchValue` is a _global_ RegExp, `replace` will be called concurrently for every match.
76
74
77
75
#### string
78
76
@@ -87,15 +85,15 @@ Type: `regexp`, `string`
87
85
88
86
An expression to match substrings to replace.
89
87
90
-
#### replaceValue
88
+
#### replace
91
89
92
90
Type: `function`, `string`
93
91
94
92
A `function` that takes [several arguments](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_function_as_a_parameter) and returns a `promise`. Resolved value will be used as _replacement substring_.
95
93
96
94
## A Note on Concurrency
97
95
98
-
Previously this module had an aditional menhod `seq()` that ran `replaceValue` functions one by one instead of all at once. We decided to remove it to cut more weight from the package. Here's a snippet that achieves the same effect:
96
+
Previously this module had aditional menhod `seq()` that ran `replace` functions one by one instead of all at once. We decided to remove it to narrow our scope. Here's a snippet that achieves the same effect:
0 commit comments