function parseTrack($str) {
[$first_part, $second_part] = explode(' - ', $str);
$first_part = preg_replace('~^\d+\. ?~', '', $first_part);
$artists = preg_split('~ feat\. |,~', $first_part);
$artist = $artists[0];
$feat = array_slice($artists, 1);
preg_match('~^(.*?)(?: \(([^(]+) prod\.?\))?$~', $second_part, $match);
return [
'artist' => $artist,
'feat' => $feat,
'name' => $match[1],
'beatmaker' => isset($match[2]) ? $match[2] : null
];
}
function sortByExt(files) {
function getFileInfo(val) {
const arr = val.split('.');
return {
ext: arr.pop(),
name: arr.join('.')
}
}
function compare(s1, s2) {
if (s1 < s2) {
return -1;
}
if (s1 > s2) {
return 1;
}
return 0;
}
return files.sort((a, b) => {
const {ext: aExt, name: aName} = getFileInfo(a);
const {ext: bExt, name: bName} = getFileInfo(b);
return compare(aExt, bExt) || compare(aName, bName);
});
}
const relatedList = el ? [el] : main.querySelectorAll('.products-wrapper');
getStyles<T extends keyof CSSStyleDeclaration>(styles: Array<T>): Record<T, string> {
return styles.reduce((res, style) => {
res[style] = this.$nativeElement.style[style];
return res;
}, {} as Record<T, string>);
}
function getTextInComments(el) {
return [...el.childNodes].reduce((acc, curr) => {
if (curr.nodeType === Node.ELEMENT_NODE) {
acc.values.push(...getTextInComments(curr));
} else if (curr.nodeType === Node.COMMENT_NODE) {
acc.isComment = !acc.isComment;
} else if (curr.nodeType === Node.TEXT_NODE && acc.isComment) {
acc.values.push(curr.textContent);
}
return acc;
}, {
values: [],
isComment: false
}).values;
}
const arr = getTextInComments(document.querySelector('.box'));
const result = mask.map((s) =>
s.startsWith('/') && s.endsWith('/') ? new RegExp(s.slice(1, -1)) : s);