mirror of
https://github.com/matheus23/elmjs-inspect.git
synced 2024-09-11 11:25:45 +03:00
Prettify names
This commit is contained in:
parent
cc21c0079f
commit
b502d39d40
@ -53,10 +53,20 @@ function pct(value: number, of: number) {
|
|||||||
return `${Number((value / of) * 100).toFixed(3)}%`;
|
return `${Number((value / of) * 100).toFixed(3)}%`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function prettyName(name: string) {
|
||||||
|
if (!name.startsWith("$")) {
|
||||||
|
return `Kernel Code: ${name}`;
|
||||||
|
}
|
||||||
|
const packageName = name.split("$").slice(1, 3).join("/");
|
||||||
|
const moduleName = name.split("$").slice(3).join(".");
|
||||||
|
return `${packageName}: ${moduleName}`;
|
||||||
|
}
|
||||||
|
|
||||||
function moduleName(name: string) {
|
function moduleName(name: string) {
|
||||||
|
const prettifiedName = prettyName(name);
|
||||||
return !name.startsWith("$")
|
return !name.startsWith("$")
|
||||||
? "Kernel Code"
|
? "Kernel Code"
|
||||||
: name.slice(0, name.lastIndexOf("$"));
|
: prettifiedName.slice(0, prettifiedName.lastIndexOf("."));
|
||||||
}
|
}
|
||||||
|
|
||||||
function packageName(name: string) {
|
function packageName(name: string) {
|
||||||
@ -107,7 +117,9 @@ export async function analyze(elmOutputJsFilePath: string, opts: any) {
|
|||||||
} else {
|
} else {
|
||||||
infos.sort((a, b) => rangeSize(b.range) - rangeSize(a.range));
|
infos.sort((a, b) => rangeSize(b.range) - rangeSize(a.range));
|
||||||
infos.forEach(({ name, range }) => {
|
infos.forEach(({ name, range }) => {
|
||||||
Console.log(`${pct(rangeSize(range), rangeSize(size))}: ${name}`);
|
Console.log(
|
||||||
|
`${pct(rangeSize(range), rangeSize(size))}: ${prettyName(name)}`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const rangeSum = infos
|
const rangeSum = infos
|
||||||
|
Loading…
Reference in New Issue
Block a user