After creates a function that invokes func once it's called n or more times. Play: https://go.dev/play/p/8mQhkFmsgqs
(n int, fn any)
| 14 | // After creates a function that invokes func once it's called n or more times. |
| 15 | // Play: https://go.dev/play/p/8mQhkFmsgqs |
| 16 | func After(n int, fn any) func(args ...any) []reflect.Value { |
| 17 | // Catch programming error while constructing the closure |
| 18 | mustBeFunction(fn) |
| 19 | |
| 20 | return func(args ...any) []reflect.Value { |
| 21 | n-- |
| 22 | if n < 1 { |
| 23 | return unsafeInvokeFunc(fn, args...) |
| 24 | } |
| 25 | return nil |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | // Before creates a function that invokes func once it's called less than n times. |
| 30 | // Play: https://go.dev/play/p/0HqUDIFZ3IL |
searching dependent graphs…