const serverAPI = {
getCategories: () => fetch('/categories'),
getCategory: (id) => fetch('/categories/' + id)
}
// Создадим базу данных
const mockDB = {
categories: [
{ id: 1, name: 'products'},
{ id: 2, name: 'services'}
]
}
const mockAPI = {
getCategories: () => Promise.resolve(mockDB.categories),
getCategory: (id) => Promise.resolve(mockDB.categories.find(v => v.id === id)),
}
const currentAPI = serverAPI
Object.assign(currentAPI, mockAPI)
Object.assign(currentAPI, serverAPI)
Что можно понять, посмотрев на данный код, и сколько кода нужно увидеть вам, что бы понять уровень разработчика?
Math.max(arrMultiplication.map(v => isNaN(v) ? -Infinity : v))
(
SELECT SUM(total_paid_real / conversion_rate)
FROM ps_orders o
WHERE o.id_customer = a.id_customer
AND o.id_shop IN (1)
AND o.valid = 1
) as total_spent,
SELECT SQL_NO_CACHE a.`id_customer`,
`firstname`,
`lastname`,
`email`,
a.`active` AS `active`,
`newsletter`,
`optin`,
a.date_add,
gl.name as title,
total_spents.total_spent
FROM `ps_customer` a
LEFT JOIN ps_gender_lang gl ON (a.id_gender = gl.id_gender AND gl.id_lang = 1)
LEFT JOIN (
SELECT o.id_customer, SUM(total_paid_real / conversion_rate) as total_spent
FROM ps_orders o
WHERE o.id_customer IN (SELECT id_customer FROM `ps_customer` a WHERE a.deleted = 0)
AND o.id_shop IN (1)
AND o.valid = 1
GROUP BY o.id_customer
) total_spents ON a.id_customer = total_spents.id_customer,
WHERE 1
AND a.`deleted` = 0
ORDER BY `date_add` DESC
LIMIT 0, 50
const deepMerge = (a, b, howDeep = 1000) => {
a = {...a}
Object.entries(b).forEach(([key, value]) => {
if (typeof value !== 'object' || howDeep < 1) {
a[key] = value
} else {
a[key] = deepMerge(a[key], value, howDeep - 1)
}
})
return a;
}
const c = deepMerge(a, b)
console.log(c)