pub fn minify<T: Write>(
top_level_mode: TopLevelMode,
source: Vec<u8>,
output: &mut T
) -> Result<(), MinifyError>Expand description
Minifies UTF-8 JavaScript code, represented as an array of bytes.
Arguments
source- A vector of bytes representing the source code to minify.output- Destination to write minified output JavaScript code.
Examples
use minify_js::{TopLevelMode, minify};
let mut code: &[u8] = b"const main = () => { let my_first_variable = 1; };";
let mut out = Vec::new();
minify(TopLevelMode::Global, code.to_vec(), &mut out).unwrap();
assert_eq!(out.as_slice(), b"const main=()=>{let a=1}");