Skip to content

Commit

Permalink
Update api docs
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed May 8, 2024
1 parent dfc52fc commit a75cda4
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions docs/api/x.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
| [x.Range](#range) ||
| [x.Reduce](#reduce) ||
| [x.RemoveRepeat](#removerepeat) |Uniq creates an array with unique values. |
| [x.Retry](#retry) |retry 对第二个参数作为函数的情况,重试N次,如果第二个参数返回值是 true,则重试,否则就结束,如果遇到错误,停止重试 |
| [x.Reverse](#reverse) |Reverse transforms an array the first element will become the last, the second element will become the second to last, etc. |
| [x.Shift](#shift) ||
| [x.Shuffle](#shuffle) |Shuffle creates an array of shuffled values |
Expand Down Expand Up @@ -568,6 +569,71 @@ Uniq creates an array with unique values.
| r1 | `any` | |


### Retry

#### 详细描述
retry 对第二个参数作为函数的情况,重试N次,如果第二个参数返回值是 true,则重试,否则就结束,如果遇到错误,停止重试

Example:
```
count = 0
retry(100, () => {
defer recover()
count++
if count > 3 {
die(111)
}
return true
})
assert count == 4, f`${count}`
count = 0
retry(100, () => {
defer recover()
count++
if count > 3 {
return false
}
return true
})
assert count == 4, f`${count}`
count = 0
retry(100, () => {
count++
})
assert count == 1, f`${count}`
count = 0
retry(100, () => {
count++
return true
})
assert count == 100, f`${count}`
```


#### 定义

`Retry(i int, handler func() bool)`

#### 参数
|参数名|参数类型|参数解释|
|:-----------|:---------- |:-----------|
| i | `int` | |
| handler | `func() bool` | |


### Reverse

#### 详细描述
Expand Down

0 comments on commit a75cda4

Please sign in to comment.