compressobj: Create a Compression Object

View source: R/zlib.R

compressobjR Documentation

Create a Compression Object

Description

compressobj initializes a new compression object with specified parameters and methods. The function makes use of publicEval to manage scope and encapsulation.

Usage

compressobj(
             level = -1,
             method = zlib$DEFLATED,
             wbits = zlib$MAX_WBITS,
             memLevel = zlib$DEF_MEM_LEVEL,
             strategy = zlib$Z_DEFAULT_STRATEGY,
             zdict = NULL
         )

Arguments

level

Compression level, default is -1.

method

Compression method, default is zlib$DEFLATED.

wbits

Window bits, default is zlib$MAX_WBITS.

memLevel

Memory level, default is zlib$DEF_MEM_LEVEL.

strategy

Compression strategy, default is zlib$Z_DEFAULT_STRATEGY.

zdict

Optional predefined compression dictionary as a raw vector.

Value

Returns an environment containing the public methods compress and flush.

Methods

  • compress(data): Compresses a chunk of data.

  • flush(): Flushes the compression buffer.

Examples

compressor <- compressobj(level = 6)
compressed_data <- compressor$compress(charToRaw("some data"))
compressed_data <- c(compressed_data, compressor$flush())


zlib documentation built on Oct. 19, 2023, 1:13 a.m.