идет смещение индексов, но как это обойти, уже не знаю
for (let i = arr.length; i--;) {
invItems.splice(arr[i], 1);
}
for (const n of [...arr].reverse()) {
invItems.splice(n, 1);
}
for (const [ i, n ] of arr.entries()) {
invItems.splice(n - i, 1);
}
invItems.splice(0, invItems.length, ...invItems.filter((n, i) => !arr.includes(i)));
let numDeleted = 0;
for (let i = 0; i < invItems.length; i++) {
invItems[i - numDeleted] = invItems[i];
numDeleted += i === arr[numDeleted];
}
invItems.length -= numDeleted;
audio.getPopular
only_eng - 1 — to return only foreign audio files, 0 — to return all audio files
genre_id - Genre ID. See the list of audio genres. (positive number)
offset - Offset needed to return a specific subset of audio files. (positive number)
count - Number of audio files to return. (positive number, maximum value 1000, default 100)
const ids = [ 9, 10 ];
const items = arr.flatMap(n => n.items);
// или
const items = Array.prototype.concat.apply([], arr.map(n => n.items));
// или
const items = arr.reduce((acc, n) => (acc.push(...n.items), acc), []);
const result = items.filter(n => ids.includes(n.id));
// или
const result = items.filter(function(n) {
return this.has(n.id);
}, new Set(ids));
// или
const itemsObj = Object.fromEntries(items.map(n => [ n.id, n ]));
const result = ids.reduce((acc, n) => ((n = itemsObj[n]) && acc.push(n), acc), []);