function

package
v2.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package function implements some functions for control the function execution and some is for functional programming.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func After

func After(n int, fn any) func(args ...any) []reflect.Value

After creates a function that invokes func once it's called n or more times

func Before

func Before(n int, fn any) func(args ...any) []reflect.Value

Before creates a function that invokes func once it's called less than n times

func Compose

func Compose(fnList ...func(...any) any) func(...any) any

Compose compose the functions from right to left

func Debounced

func Debounced(fn func(), duration time.Duration) func()

Debounced creates a debounced function that delays invoking fn until after wait duration have elapsed since the last time the debounced function was invoked.

func Delay

func Delay(delay time.Duration, fn any, args ...any)

Delay make the function execution after delayed time

func Schedule

func Schedule(d time.Duration, fn any, args ...any) chan bool

Schedule invoke function every duration time, util close the returned bool chan

Types

type Fn

type Fn func(...any) any

Fn is for curry function which is func(...any) any

func (Fn) Curry

func (f Fn) Curry(i any) func(...any) any

Curry make a curry function

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher is used for record code excution time

func (*Watcher) GetElapsedTime

func (w *Watcher) GetElapsedTime() time.Duration

GetElapsedTime get excute elapsed time.

func (*Watcher) Reset

func (w *Watcher) Reset()

Reset the watch timer.

func (*Watcher) Start

func (w *Watcher) Start()

Start the watch timer.

func (*Watcher) Stop

func (w *Watcher) Stop()

Stop the watch timer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL