export function httpString(s) {
return s.split(' ').filter(_ => ~_.indexOf('src="'))
.map(_ => _.replace(/src="|"/gi, ''));
}
export const top = (list, topId, optType) => {
const srcList = list.slice(0);
const targetIdx = list.findIndex(el => el.id === topId);
if (targetIdx < 0) {
return srcList;
}
const optId = list.findIndex(el => el.top !== 1);
const targetSession = srcList.splice(targetIdx, 1)[0];
if (optType === 1) {
srcList.unshift({
...targetSession,
top: 1,
});
}
if (optType === 0) {
srcList.splice(targetSession.top !== 1 ? (optId || 0) : targetIdx, 0, targetSession);
}
if (optType === -1) {
srcList.push({
...targetSession,
top: 0,
});
}
return srcList;
};