notes

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter(ctx context.Context, notes <-chan Note, predicates ...Predicate) (note <-chan Note, errors <-chan error)

func FindTagByName

func FindTagByName(note Note, name string) (tag.Tag, bool, error)

func Top

func Top(ctx context.Context, limit int, notes <-chan Note, less Less) (note <-chan Note, errors <-chan error)

Types

type Less

type Less func(i, j Note) (bool, error)
var CreatedAsc Less = func(first, second Note) (bool, error) {
	firstCreated, e := first.Created()
	if e != nil {
		return false, e
	}
	secondCreated, e := second.Created()
	if e != nil {
		return false, e
	}
	return firstCreated.Before(secondCreated), nil
}
var CreatedDesc Less = func(first, second Note) (bool, error) {
	firstCreated, e := first.Created()
	if e != nil {
		return false, e
	}
	secondCreated, e := second.Created()
	if e != nil {
		return false, e
	}
	return firstCreated.After(secondCreated), nil
}
var ModifiedAsc Less = func(i, j Note) (bool, error) {
	firstModified, e := i.Modified()
	if e != nil {
		return false, e
	}
	secondModified, e := j.Modified()
	if e != nil {
		return false, e
	}
	return firstModified.Before(secondModified), nil
}
var ModifiedDesc Less = func(i, j Note) (bool, error) {
	firstModified, e := i.Modified()
	if e != nil {
		return false, e
	}
	secondModified, e := j.Modified()
	if e != nil {
		return false, e
	}
	return firstModified.After(secondModified), nil
}

func TagDateAsc

func TagDateAsc(name string) Less

func TagDateDesc

func TagDateDesc(name string) Less

func TagNumberAsc

func TagNumberAsc(name string) Less

func TagNumberDesc

func TagNumberDesc(name string) Less

type Note

type Note interface {
	Modified() (time.Time, error)
	Created() (time.Time, error)
	Path() string
	Tags() ([]tag.Tag, error)
	Body() (string, error)
}

type Predicate

type Predicate func(note Note) (bool, error)

func CreatedAfter

func CreatedAfter(createdAfter string) (Predicate, error)

func CreatedBefore

func CreatedBefore(createdBefore string) (Predicate, error)

func Grep

func Grep(expr string) (Predicate, error)

func ModifiedAfter

func ModifiedAfter(modifiedAfter string) (Predicate, error)

func ModifiedBefore

func ModifiedBefore(modifiedBefore string) (Predicate, error)

func NoTag

func NoTag(t string) Predicate

func NoTags

func NoTags() Predicate

func Tag

func Tag(t string) Predicate

func TagAfter

func TagAfter(tagNameValue string) (Predicate, error)

func TagBefore

func TagBefore(tagNameValue string) (Predicate, error)

func TagGreater

func TagGreater(tagNameValue string) (Predicate, error)

func TagGrep

func TagGrep(regex *regexp.Regexp) Predicate

func TagLower

func TagLower(tagNameValue string) (Predicate, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳