function removeSomeShit(arr) {
const table = {};
const result = [];
for(const current of arr) {
const {uid, owner, createdAt} = current;
const uidOvnerKey = `${uid}\0${owner}`;
const ownerUidKey = `${owner}\0${uid}`;
const matched = table[uidOvnerKey];
if (matched) {
delete table[uidOvnerKey];
result.push(matched.createdAt > createdAt ? matched : current);
} else {
table[ownerUidKey] = current;
}
};
return Object.values(table).concat(result);
} function isPermittedObject(obj) {
if (!obj) return false;
const permitted = new Set(["v", "c", "g"]);
let max = 1;
for (const key in obj)
if (!permitted.has(key) || !max--)
return false;
return true;
}
console.log(!isPermittedObject({
v: 1,
c: 3,
g: 5
}))
console.log(!isPermittedObject({
v: 1
})) class Users {
constructor() {
this.store = []
}
[Symbol.iterator] = () => this.store[Symbol.iterator]()
} Но взможно вам проще и красивее будет сделать самих User'ов наследником массива: class Users extends Array {
constructor() {
super();
}
} И использовать сразу this вместо this.store со всеми методами массива кроме тех которые вы переопределите:). function slow(x) { ... }var slow;
slow = function (x) { ... };slow = cachingDecorator(slow);items.forEach(item => item.alert = false) const [selected, setSelected] = useState('all');
let filterdTodos;
switch(selected) {
case 'all':
filterdTodos = todos;
break;
case 'checked':
filterdTodos = todos.filter(t => t.checked);
break;
case 'notChecked':
filterdTodos = todos.filter(t => !t.checked);
break;
}const [selected, setSelected] = useState('all');
const filterdTodos = useMemo(() => {
switch(selected) {
case 'all':
return todos;
case 'checked':
return todos.filter(t => t.checked);
case 'notChecked':
return todos.filter(t => !t.checked);
}
}, [selected, todos])<select className="todos__filter" onChange={(event) =>setSelected(event.target.value)}>
...
{filterdTodos.map(...)} products должны быть ref. Сейчас они не реактивны(никак не реагируют на изменения). При этом ты присваииваешь массиву value. То что это хоть как-то работало - очередное чудо.export const useAllMainFiltersStore = defineStore('allMainFilters', () => {
const products = ref([]);
try {
async function getStoreData() {
sidebarResizeStore.updateSidebarVisibility()
const data = await productsData();
products.value = data;
}
getStoreData()
} catch (error) {
console.error('Error:', error);
}
return {
products,
}
})const route = useRoute();
// продукт делаем вычисляемым, чтоб не городить вотчеров
const product = computed(() => getProductById(route.params.id));
function getProductById(id) {
console.log('products component: ', mainFiltersStore.products) //при первой загрузке всё ок, при перезагрузке страницы всё ломается и пустой массив в придачу
return products.find(product => product.id == id);
}
watch(product, current => {
// проверяем что продукт есть
if (current) fetchComments(current.id);
}, { immediate: true }) inline, тут используется кастомный иконсет settings. input нет свойства length.var intxt=document.querySelector('input').length;intxt === undefinedconsole.log вообще-то должен был тебе это показать.if(intxt.length<5){ тут ты пытаешься получить свойство length у unefined о чем тебе и пишет ошибка.var intxt=document.querySelector('input');
....
if(intxt.value.length<5){
....
} else { async function multiStep() {
await step1();
if (stop) throw new Error(stop);
await step2();
if (stop) throw new Error(stop);
await step3();
if (stop) throw new Error(stop);
} и никак красивее не сделать. function* multiStep() {
yield step1();
yield step2();
yield step3();
}import { ref, h } from 'vue';
function loadScript(options, root = document.head) {
return root.appendChild(Object.assign(document.createElement('script'), options));
}
const Comp = defineComponent(() => {
const root = ref(null);
onMounted(() => {
loadScript(
{
innerHTML: `
!(function (a, m, o, c, r, m) {
(a[o + c] = a[o + c] || {
setMeta: function (p) {
this.params = (this.params || []).concat([p]);
},
}),
(a[o + r] =
a[o + r] ||
function (f) {
a[o + r].f = (a[o + r].f || []).concat([f]);
}),
a[o + r]({
id: "....",
hash: "....",
locale: "ru",
}),
(a[o + m] =
a[o + m] ||
function (f, k) {
a[o + m].f = (a[o + m].f || []).concat([[f, k]]);
});
})(window, 0, "amo_forms_", "params", "load", "loaded");
`
},
root.value
);
loadScript(
{
id: 'amoforms_script_...',
async: 'async',
charset: 'utf-8',
src: 'https://forms.amocrm.ru/forms/assets/js/amoforms.js?...'
},
root.value
);
});
return () => h('div', { ref: root });
}); script type="module" через import(никаких глобальных вызовов)./browse.<script type="importmap">
{
"imports": {
"tictic": "https://unpkg.com/tictic@0.1.0/esm/index.js",
"tslib": "https://unpkg.com/tslib@2.6.2/tslib.es6.js"
}
}
</script>
<script type="module">
import { getDate } from 'tictic';
console.log(getDate({}));
</script>[role="row"]:has(.fraud) {
background-color: #f1f7bc;
}[role="row"] {
position: relative;
background-color: transparent;
}
[role="row"] .fraud::before {
content: "";
display: block;
position: absolute;
z-index: -1;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: #f1f7bc;
}MutationObserver и следить за появлением новых [role="row"].