selectors

package
v0.0.0-...-bba8168 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package selectors provides utilities to compile and cache CSS selectors.

The package provides a cache implementation that caches selectors in-memory using a `sync.Map`, it also exposes the same methods to compile selectors using a global cache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(selector string) (cascadia.Selector, error)

Compile compiles the given selector.

It uses a global pre-initialized cache of selectors.

Types

type Cache

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

Cache implementation.

func NewCache

func NewCache() *Cache

NewCache returns a new cache.

func (*Cache) Compile

func (c *Cache) Compile(selector string) (cascadia.Selector, error)

Compile compiles the given selector.

The method returns an error if the selector is invalid subsequent calls return the cached selector.

Jump to

Keyboard shortcuts

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