Skip to content

Commit dd4f912

Browse files
committed
fixed readme
1 parent 14ddc42 commit dd4f912

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

README.md

+19-12
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ p := Promise.Create(func(resolve Promise.Callback, reject Promise.Callback) {
181181

182182

183183

184-
* Want bunch of Promises executed at once 👀 Note:
185-
These are position aware nothing is jumbled
184+
* Want bunch of Promises executed at once 👀
185+
Note: These are position aware nothing is jumbled
186186
```golang
187187

188188

@@ -255,9 +255,14 @@ for value := range Promise.AsyncGenerator(promises) {
255255
fmt.Println(value)
256256
}
257257

258-
```
258+
```
259+
260+
261+
262+
259263

260-
*My Map is all parallel , can I have a reduce, that pipelines with request delays ? 👩‍⚖️
264+
265+
* My Map is all parallel , can I have a reduce, that pipelines with request delays ? 👩‍⚖️
261266
Yes the Reduce provided here internally uses AsyncGenerator to grab data and quicly
262267
launch promise task to to luanch reducer for each data. Effectively pipelining with
263268
the promises passsed to it.
@@ -269,17 +274,19 @@ for value := range Promise.AsyncGenerator(promises) {
269274
promises := make([]*Promise.Promise, 3)
270275
for i := 0; i < len(promises); i++ {
271276
index := i
272-
promises[i] = Promise.Create(func(resolve Promise.Callback, reject Promise.Callback) {
273-
time.Sleep(time.Duration(index)*time.Second + time.Duration(10))
274-
resolve(index + 1)
277+
promises[i] = Promise.Create(
278+
func(resolve Promise.Callback, reject Promise.Callback) {
279+
time.Sleep(time.Duration(index)*time.Second + time.Duration(10))
280+
resolve(index + 1)
275281
})
276282
}
277283

278-
value := Promise.Reduce(promises, func(index int, acci interface{}, valuei interface{}) interface{} {
279-
acc, _ := acci.(int)
280-
value, _ := valuei.(int)
281-
acc = value + acc
282-
return acc
284+
value := Promise.Reduce(promises,
285+
func(index int, acci interface{}, valuei interface{}) interface{} {
286+
acc, _ := acci.(int)
287+
value, _ := valuei.(int)
288+
acc = value + acc
289+
return acc
283290
}, 0).Finally(nil)
284291

285292
```

0 commit comments

Comments
 (0)