A collection of tools and utilities to "unfuck" minified and webpack'd javascript sources.
loopTillStable(input, processor, limit = 10)
Recursively applies a text processor until the output is stable or the limit is reached. Returns the last output from the processor.
input
- The input string.processor
- A function that takes the input string as it's first parameter and returns the processed output.limit
- Optional. Defaults to 10. The maximum number of iterations.
splitWebpackModules(input)
Splits a webpack'd file into it's modules. Returns a map of module ids to the module contents. Throws a RangeError
if the input was not recognized.
Note, this doesn't generate any shim code - the modules will not be able to resolve each other without additional changes.
input
- The input string.
Map(3) {
1 => "{ foo() }"
2 => "{ bar() }"
3 => "{ baz() }"
}
A collection of auto-fixers for ESLint to un-minify code or increase it's readability.
Disallows using short-circuit logical expressions as if statements.
For example:
{
foo && bar()
}
Will be fixed to:
{
if (foo) bar()
}
Disallows using ternary expressions as if/else statements.
For example:
{
foo ? bar() : baz()
}
Will be fixed to:
{
if (foo) { bar() } else { baz() }
}
Disallows using scientific notation for small numbers.
For example:
1E3
Will be fixed to:
1000
Disallows using the comma operator to join expression statements into a sequence.
For example:
{
foo(), bar(), baz();
}
Will be fixed to:
{
foo(); bar(); baz();
}
Adds parentheses around operators where operator precidence may be confusing (This one's opinionated).
For example:
32 << 5 >> 3 & 5 + 3 - 4
Will be fixed to:
((32 << 5) >> 3) & (5 + 3 - 4)
Disallows reusing variables for other assignments.
For example:
let foo = 0
log(foo)
foo = 1
log(foo)
Will be fixed to:
let foo = 0
log(foo)
let foo_2 = 1
log(foo_2)
TODO
TODO
TODO