2021-07-07 23:50:57 +03:00
|
|
|
import * as Validations from "~/common/validations";
|
|
|
|
|
2021-06-10 22:54:26 +03:00
|
|
|
export const filterPublic = (arr = []) => {
|
|
|
|
return arr.filter((item) => item.isPublic);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const filterPrivate = (arr = []) => {
|
|
|
|
return arr.filter((item) => !item.isPublic);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const mapToIds = (arr = []) => {
|
|
|
|
return arr.map((item) => item.id);
|
|
|
|
};
|
|
|
|
|
2021-07-07 23:50:57 +03:00
|
|
|
export const mapToCids = (arr = []) => {
|
|
|
|
return arr.map((item) => item.cid);
|
|
|
|
};
|
|
|
|
|
2021-06-10 22:54:26 +03:00
|
|
|
export const countPublic = (arr = []) => {
|
2021-06-11 08:12:24 +03:00
|
|
|
const reducer = (count, item) => {
|
2021-06-10 22:54:26 +03:00
|
|
|
if (item.isPublic) return count + 1;
|
|
|
|
else return count;
|
2021-06-11 08:12:24 +03:00
|
|
|
};
|
|
|
|
return arr.reduce(reducer, 0);
|
2021-06-10 22:54:26 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export const countPrivate = (arr = []) => {
|
2021-06-11 08:12:24 +03:00
|
|
|
const reducer = (count, item) => {
|
2021-06-10 22:54:26 +03:00
|
|
|
if (!item.isPublic) return count + 1;
|
|
|
|
else return count;
|
2021-06-11 08:12:24 +03:00
|
|
|
};
|
|
|
|
return arr.reduce(reducer, 0);
|
2021-06-10 22:54:26 +03:00
|
|
|
};
|
2021-07-07 23:50:57 +03:00
|
|
|
|
|
|
|
export const filterLinks = (arr = []) => {
|
|
|
|
return arr.filter((item) => item.isLink);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const filterFiles = (arr = []) => {
|
|
|
|
return arr.filter((item) => !item.isLink);
|
|
|
|
};
|