mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-06 01:18:23 +08:00
Add md_prefix and print_path functions
This commit is contained in:
26
.github/workflows/script.js
vendored
26
.github/workflows/script.js
vendored
@ -30,7 +30,31 @@ function good_filepaths(top_dir = ".") {
|
||||
})
|
||||
}
|
||||
|
||||
function md_prefix(i) {
|
||||
if (i) {
|
||||
let res = ' '.repeat(i);
|
||||
return res + "*";
|
||||
} else {
|
||||
return "\n##"
|
||||
}
|
||||
}
|
||||
|
||||
function print_path(old_path, new_path) {
|
||||
let old_parts = old_path.split(path.sep);
|
||||
let new_parts = new_path.split(path.sep);
|
||||
for (let i = 0; i < new_parts.length; ++i) {
|
||||
let new_part = new_parts[i];
|
||||
if (i + 1 > old_parts.len || old_parts[i] != new_part) {
|
||||
if (new_part) {
|
||||
g_output.push(`${md_prefix(i)} ${new_part.replace('_', ' ')}`);
|
||||
// console.log(`${md_prefix(i)} ${new_part.replace('_', ' ')}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new_path;
|
||||
}
|
||||
|
||||
good_filepaths();
|
||||
setTimeout(() => {
|
||||
console.log(filepaths.length);
|
||||
console.log(filepaths);
|
||||
}, 1000);
|
Reference in New Issue
Block a user