mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-13 05:15:53 +02:00
make more use of generics
This commit is contained in:
parent
dde30fa104
commit
c7a629c440
52 changed files with 3013 additions and 274 deletions
19
vendor/github.com/samber/lo/retry.go
generated
vendored
Normal file
19
vendor/github.com/samber/lo/retry.go
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
package lo
|
||||
|
||||
// Attempt invokes a function N times until it returns valid output. Returning either the caught error or nil. When first argument is less than `1`, the function runs until a sucessfull response is returned.
|
||||
func Attempt(maxIteration int, f func(int) error) (int, error) {
|
||||
var err error
|
||||
|
||||
for i := 0; maxIteration <= 0 || i < maxIteration; i++ {
|
||||
// for retries >= 0 {
|
||||
err = f(i)
|
||||
if err == nil {
|
||||
return i + 1, nil
|
||||
}
|
||||
}
|
||||
|
||||
return maxIteration, err
|
||||
}
|
||||
|
||||
// throttle ?
|
||||
// debounce ?
|
Loading…
Add table
Add a link
Reference in a new issue