data

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyVersionRange

func ApplyVersionRange(versions []uagenerator.VersionSpec, vr uagenerator.VersionRange) []uagenerator.VersionSpec

ApplyVersionRange filters a slice of VersionSpec by a VersionRange. Returns the filtered slice. If the filter results in an empty slice, the original slice is returned unchanged (matching Python behavior).

func ApplyWeightedVersions

func ApplyWeightedVersions(versions []uagenerator.VersionSpec, rng *rand.Rand, maxRange int) []uagenerator.VersionSpec

ApplyWeightedVersions applies weighted random selection biased toward newer (later) versions. It returns a single-element slice containing the selected version. maxRange controls how many of the newest versions get extra weight (default behavior uses maxRange=4).

func FilterVersions

func FilterVersions(versions []uagenerator.VersionSpec, opts *uagenerator.Options, key string, rng *rand.Rand, maxRange int) []uagenerator.VersionSpec

FilterVersions applies optional VersionRange and weighted selection to a version list. This is the common pattern used by all browser/platform GetVersion functions.

Types

type Generator

type Generator struct {
	Device   string
	Platform string
	Browser  string
	Options  *uagenerator.Options

	PlatformVersion uagenerator.Version
	BrowserVersion  uagenerator.Version

	// Typed versions — non-nil only for the matching platform/browser type
	WindowsVer  *uagenerator.WindowsVersion
	AndroidVer  *uagenerator.AndroidVersion
	ChromiumVer *uagenerator.ChromiumVersion
	SafariVer   *uagenerator.SafariVersion

	UserAgent string
}

Generator picks platform and browser versions, then assembles the user-agent string.

func NewGenerator

func NewGenerator(device, platform, browser string, opts *uagenerator.Options, rng *rand.Rand) *Generator

NewGenerator creates a Generator by picking versions and assembling the UA string.

func (*Generator) ToGeneratorData

func (g *Generator) ToGeneratorData() *uagenerator.GeneratorData

ToGeneratorData converts this Generator into a GeneratorData value suitable for the root package (ClientHints, Headers, Navigator).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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