brotliKit

package
v3.0.922 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelDefaultCompression = brotli.DefaultCompression

	LevelBestSpeed       = brotli.BestSpeed
	LevelBestCompression = brotli.BestCompression
)

Variables

View Source
var (
	NewWriter func(dst io.Writer) *brotli.Writer = brotli.NewWriter

	NewWriterWithLevel func(dst io.Writer, level int) *brotli.Writer = brotli.NewWriterLevel

	NewReader func(src io.Reader) *brotli.Reader = brotli.NewReader
)

Functions

func AssertValidLevel added in v3.0.61

func AssertValidLevel(level int) error

func Compress

func Compress(data []byte, options ...Lz4Option) (compressed []byte, err error)

Compress

PS: (1) 参考 github.com/andybalholm/brotli 中的 "example_test.go". (2) 前端的解压,可以参考 notes/_Vue3Projects/ws-client 中的 BrotliKit.

func Decompress

func Decompress(compressed []byte) ([]byte, error)

Decompress

PS: 参考 github.com/andybalholm/brotli 中的 "example_test.go".

func IsValidLevel added in v3.0.61

func IsValidLevel(level int) bool

IsValidLevel

@param level 有效范围: [0, 11]

Types

type Config added in v3.0.61

type Config struct {
	Level int `json:"level" yaml:"level" validate:"min=0,max=11"`

	CompressThreshold int `json:"compressThreshold" yaml:"compressThreshold"`
}

type Lz4Option added in v3.0.61

type Lz4Option func(opts *lz4Options)

func WithCompressThreshold added in v3.0.61

func WithCompressThreshold(compressThreshold int) Lz4Option

WithCompressThreshold 设置: 最小压缩长度阈值

func WithLevel added in v3.0.61

func WithLevel(level int) Lz4Option

Jump to

Keyboard shortcuts

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