Refactor getChildrenCount (#3554)
Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
This commit is contained in:
parent
34235d4d44
commit
f6f79fb388
1 changed files with 2 additions and 9 deletions
|
@ -16,15 +16,8 @@ function getTextCount(tokens: Node[]): number {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChildrenCount(tokens: Node[]): number {
|
function getChildrenCount(tokens: Node[]): number {
|
||||||
let count = 0;
|
const countTree = tokens.filter(x => x.children).map(x => getChildrenCount(x.children));
|
||||||
const extract = (tokens: Node[]) => {
|
return countTree.length + sum(countTree);
|
||||||
tokens.filter(x => x.children).forEach(x => {
|
|
||||||
count++;
|
|
||||||
extract(x.children);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
extract(tokens);
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Vue.component('misskey-flavored-markdown', {
|
export default Vue.component('misskey-flavored-markdown', {
|
||||||
|
|
Loading…
Reference in a new issue