Module js

Source

Structs§

Tokens

Enums§

Condition
Keyword
Operation
ReservedChar
Token

Functions§

aggregate_strings
Aggregate litteral strings. For instance, if the string litteral “Oh look over there!” appears more than once, a variable will be created with this value and used everywhere the string appears. Of course, this replacement is only performed when it allows to take less space.
aggregate_strings_into_array
Aggregate litteral strings. For instance, if the string litteral “Oh look over there!” appears more than once, it will be added to the generated array and used everywhere the string appears. Of course, this replacement is only performed when it allows to take less space.
aggregate_strings_into_array_filter
Same as aggregate_strings_into_array except it allows certain strings to not be aggregated thanks to the filter parameter. If it returns false, then the string will be ignored.
aggregate_strings_into_array_with_separation
Exactly like aggregate_strings_into_array except this one expects a separation token to be passed. This token will be placed between the created array for the strings aggregation and the rest.
aggregate_strings_into_array_with_separation_filter
Same as aggregate_strings_into_array_with_separation except it allows certain strings to not be aggregated thanks to the filter parameter. If it returns false, then the string will be ignored.
aggregate_strings_with_separation
Exactly like aggregate_strings except this one expects a separation token to be passed. This token will be placed between the created variables for the strings aggregation and the rest.
clean_token
Returns true if the token is a “useful” one (so not a comment or a “useless” character).
clean_token_except
Returns true if the token is a “useful” one (so not a comment or a “useless” character).
clean_tokens
Convenient function used to clean useless tokens in a token list.
clean_tokens_except
Same as clean_tokens except that if a token is considered as not desired, the callback is called. If the callback returns false as well, it will be removed.
get_variable_name_and_value_positions
When looping over Tokens, if you encounter Keyword::Var, Keyword::Let or Token::Other using this function will allow you to get the variable name’s position and the variable value’s position (if any).
minify
Minifies a given JS source code.
replace_token_with
Replace a given token with another.
replace_tokens_with
Replace given tokens with others.
simple_minify
Simple function to get the untouched token list. Useful in case you want to perform some actions directly on it.
tokenize