PD
Size: a a a
PD
P
PD
P
PD
P
PD
P
PD
P
PD
PD
P
PD
IL
Object.defineProperty()
IL
PD
function cutComments(commentsArray) {
const lengthOfList = subCommentsLimit;
// console.log(comments);
let comments = commentsArray;
//in every parent comment we kepp only some numbers of comments
comments.forEach((element) => {
//we check the children length it is need for correct render
element.childrenLength = element.children.length;
//we reverse the array to sort elements by Date
element.children.reverse();
//We only kepp some nth elements because it is not good to render all comment for once
element.children = element.children.slice(0, lengthOfList);
//we check if comment have quote and if yes we check if quoted comment is not deleted it is need for correct render ejs
element.children.forEach((child) => {
if (child.quote.commentId) {
if (!child.quote.commentId.text) {
child.quote.commentId = false;
} else {
child.quote.commentId = child.quote.commentId.id;
}
}
});
});
console.log(comments);
//console.log(comments);
return comments;
}
PD
Object.defineProperty()
IL