mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
30 lines
583 B
JavaScript
30 lines
583 B
JavaScript
// js/feedEngine/utils.js
|
|
|
|
export function isPlainObject(value) {
|
|
if (value === null || typeof value !== "object") {
|
|
return false;
|
|
}
|
|
const prototype = Object.getPrototypeOf(value);
|
|
return prototype === Object.prototype || prototype === null;
|
|
}
|
|
|
|
export function toSet(values) {
|
|
if (values instanceof Set) {
|
|
return new Set(values);
|
|
}
|
|
if (Array.isArray(values)) {
|
|
return new Set(values);
|
|
}
|
|
return new Set();
|
|
}
|
|
|
|
export function toArray(value) {
|
|
if (!value) {
|
|
return [];
|
|
}
|
|
if (Array.isArray(value)) {
|
|
return [...value];
|
|
}
|
|
return [value];
|
|
}
|