function

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 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 interface{}) func(args ...interface{}) []reflect.Value

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

func Before

func Before(n int, fn interface{}) func(args ...interface{}) []reflect.Value

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

func Compose

func Compose(fnList ...func(...interface{}) interface{}) func(...interface{}) interface{}

Compose compose the functions from right to left

func Debounced added in v1.2.2

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 interface{}, args ...interface{})

Delay make the function execution after delayed time

func Schedule

func Schedule(d time.Duration, fn interface{}, args ...interface{}) chan bool

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

Types

type Fn

type Fn func(...interface{}) interface{}

Fn is for curry function which is func(...interface{}) interface{}

func (Fn) Curry

func (f Fn) Curry(i interface{}) func(...interface{}) interface{}

Curry make a curry function

type Watcher added in v1.1.5

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

Watcher is used for record code excution time

func (*Watcher) GetElapsedTime added in v1.1.5

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

GetElapsedTime get excute elapsed time.

func (*Watcher) Reset added in v1.1.5

func (w *Watcher) Reset()

Reset the watch timer.

func (*Watcher) Start added in v1.1.5

func (w *Watcher) Start()

Start the watch timer.

func (*Watcher) Stop added in v1.1.5

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