common

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 15 Imported by: 8

Documentation

Index

Constants

View Source
const (
	AttrNameStyle = "style"
)
View Source
const RandomUserAgent = "*"

Variables

View Source
var (
	ErrReadOnly    = core.Error(core.ErrInvalidOperation, "read only")
	ErrInvalidPath = core.Error(core.ErrInvalidOperation, "invalid path")
)
View Source
var Attributes = []string{}/* 135 elements not displayed */

Functions

func CloseAll added in v0.10.0

func CloseAll(logger zerolog.Logger, closers []io.Closer, msg string)

func CollectFrames added in v0.8.0

func CollectFrames(ctx context.Context, receiver *values.Array, doc drivers.HTMLDocument) error

func DeserializeStyles added in v0.7.0

func DeserializeStyles(input values.String) (*values.Object, error)

func FromHTMLType added in v0.8.0

func FromHTMLType(nt html.NodeType) int

func GetInDocument added in v0.7.0

func GetInDocument(ctx context.Context, path []core.Value, doc drivers.HTMLDocument) (core.Value, core.PathError)

func GetInElement added in v0.7.0

func GetInElement(ctx context.Context, path []core.Value, el drivers.HTMLElement) (core.Value, core.PathError)

func GetInNode added in v0.7.0

func GetInNode(ctx context.Context, path []core.Value, node drivers.HTMLNode) (core.Value, core.PathError)

func GetInPage added in v0.8.0

func GetInPage(ctx context.Context, path []core.Value, page drivers.HTMLPage) (core.Value, core.PathError)

func GetUserAgent

func GetUserAgent(val string) string

func IsAttribute

func IsAttribute(name string) bool

func NewIterator added in v0.7.0

func NewIterator(
	node drivers.HTMLElement,
) (core.Iterator, error)

func PathToString added in v0.7.0

func PathToString(path []core.Value) string

func SerializeStyles added in v0.7.0

func SerializeStyles(_ context.Context, styles *values.Object) values.String

func SetInDocument added in v0.7.0

func SetInDocument(ctx context.Context, path []core.Value, doc drivers.HTMLDocument, value core.Value) core.PathError

func SetInElement added in v0.7.0

func SetInElement(ctx context.Context, path []core.Value, el drivers.HTMLElement, value core.Value) core.PathError

func SetInNode added in v0.7.0

func SetInNode(_ context.Context, path []core.Value, _ drivers.HTMLNode, _ core.Value) core.PathError

func SetInPage added in v0.8.0

func SetInPage(ctx context.Context, path []core.Value, page drivers.HTMLPage, value core.Value) core.PathError

func ToHTMLType

func ToHTMLType(input int) html.NodeType

Types

type Iterator added in v0.7.0

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

func (*Iterator) Next added in v0.7.0

func (iterator *Iterator) Next(ctx context.Context) (value core.Value, key core.Value, err error)

type LazyValue

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

LazyValue represents a value with late initialization

func NewLazyValue

func NewLazyValue(factory LazyValueFactory) *LazyValue

func (*LazyValue) Mutate added in v0.8.0

func (lv *LazyValue) Mutate(ctx context.Context, mutator func(v core.Value, err error))

Mutate safely mutates an underlying value. Loads a value if it's not ready. Thread safe.

func (*LazyValue) MutateIfReady added in v0.8.0

func (lv *LazyValue) MutateIfReady(mutator func(v core.Value, err error))

MutateIfReady safely mutates an underlying value only if it's ready.

func (*LazyValue) Read

func (lv *LazyValue) Read(ctx context.Context) (core.Value, error)

Read returns an underlying value. Not thread safe. Should not mutated. @returns (Value) - Underlying value if successfully loaded, otherwise error

func (*LazyValue) Ready

func (lv *LazyValue) Ready() bool

Ready indicates whether the value is ready. @returns (Boolean) - Boolean value indicating whether the value is ready.

func (*LazyValue) Reload added in v0.8.0

func (lv *LazyValue) Reload(ctx context.Context)

Reload resets the storage and loads data.

func (*LazyValue) Reset

func (lv *LazyValue) Reset()

Reset resets the storage. Next call of Read will trigger the factory function again.

type LazyValueFactory added in v0.7.0

type LazyValueFactory func(ctx context.Context) (core.Value, error)

LazyValueFactory represents a value initializer

Jump to

Keyboard shortcuts

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