Module utils

Source
Expand description

PNG decode/encode and load functions, console log macros, argument parsing from javascript input to inner-crate rust types and other utility functions.

Structs§

NodeFs

Functions§

build_algorithm
Attempts to parse a &String to a BlendAlgorithm. Returns the enum variant if it suceeds. Otherwise it returns a PConvertError.
build_params
Attempts to build a vector of blending operations and extra parameters. One pair per blending operation. Returns a PConvertError if it fails parsing.
encode_file
Receives png buffer data and encodes it as a File with specified CompressionType and FilterType.
encode_image_data
Receives png buffer data and encodes it as an ImageData object with specified CompressionType and FilterType.
get_compression_type
Retrieves the image::codecs::png::CompressionType value from the HashMap<String, JSONValue> map if it exists. Otherwise it returns the default value: CompressionType::Fast.
get_filter_type
Retrieves the image::codecs::png::FilterType value from the HashMap<String, JSONValue> map if it exists. Otherwise it returns the default value: FilterType::NoFilter.
load_png
Receives a File and returns the decoded PNG byte buffer.
log
log_benchmark
Logs one line (algorithm, compression, filter, blend time, read time, write time) of the benchmarks table to the browser console (with console.log).
log_benchmark_header
Logs the header/column names of the benchmarks table to the browser console (with console.log).
node_read_file_async
Rust Future from nodejs fs.readFile Promise (awaitable in node).
node_read_file_sync
Wrapper function for nodejs fs.readFileSync.
node_require
node_write_file_sync
Wrapper function for nodejs fs.writeFileSync.