$t = unserialize('a:2:{i:0;s:15:"_identity-admin";i:1;s:14:"[3,null,21600]";}');
var_dump($t);
// array(2) {
// [0] => string(15) "_identity-admin"
// [1] => string(14) "[3,null,21600]"
// }
<page-following>
<page-header
title="Following"
:buttons="buttons"
@buttonPressed="onButtonPressed"
/>
<!-- здесь контент -->
<page-footer />
</page-following>
const parseDate = (date) => Date.parse(date.split('/').reverse().join('-'));
const findClosest = (list, date = (new Date()).toLocaleDateString('en-GB')) => {
const findDate = parseDate(date);
return list.reduce(
(acc, cur) => {
const delta = parseDate(cur.date) - findDate;
return (delta >= 0 && delta < acc.delta) ? { delta, el: cur } : acc;
},
{ delta: Number.MAX_SAFE_INTEGER, el: null },
).el;
};
WITH RECURSIVE `cte` (`date`) AS (
SELECT :from_date
UNION
SELECT `date` + INTERVAL 1 DAY
FROM `cte`
WHERE `date` < :to_date
)
SELECT `cte`.`date`,
IFNULL(`s`.`count`, 0) AS `joined_count`,
IFNULL(`u`.`count`, 0) AS `left_count`
FROM `cte`
LEFT JOIN (
SELECT `joined_date`, COUNT(*) AS `count`
FROM `table`
WHERE `joined_date` BETWEEN :from_date AND :to_date
GROUP BY `joined_date`
) AS `s` ON `s`.`joined_date` = `cte`.`date`
LEFT JOIN (
SELECT `left_date`, COUNT(*) AS `count`
FROM `table`
WHERE `left_date` BETWEEN :from_date AND :to_date
GROUP BY `left_date`
) AS `u` ON `u`.`left_date` = `cte`.`date`
deepEqual({a: 1}, {b: 1}); // true
deepEqual(null, {b: 1}); // 1
deepEqual({a: 1, b: 2}, {b: 2, a: 1}); // false
const deepEqual = (a, b) => {
if (a === b) {
return true;
}
if (a === null || b === null || typeof a !== 'object' || typeof b !== 'object') {
return false;
}
const aKeys = Object.keys(a);
const bKeys = Object.keys(b);
if (aKeys.length !== bKeys.length) {
return false;
}
for (let i = 0; i < aKeys.length; i += 1) {
const key = aKeys[i];
if (!bKeys.includes(key) || !deepEqual(a[key], b[key])) {
return false;
}
}
return true;
};
listToArray(arrayToList([1, 2, 3])); // Array(3) [ 3, 2, 1 ]
const list = {
value: 2,
rest: {
value: 3,
rest: null,
},
};
prepend(1, list);
/*
Object {
value: 1,
rest: Object {
value: 3,
rest: Object {
value: 2,
rest: null
}
}
}
*/
const arrayToList = (arr, idx = 0) => ({
value: arr[idx],
rest: idx === arr.length - 1
? null
: arrayToList(arr, idx + 1)
});
const listToArray = (list) => (
list.rest === null
? [list.value]
: [list.value, ...listToArray(list.rest)]
);
const prepend = (value, rest) => ({ value, rest });
const nth = (list, idx) => (
idx === 0
? list.value
: (
list.rest === null
? undefined
: nth(list.rest, idx - 1)
)
);
const arrayToList = (arr) => {
const list = null;
for (let i = arr.length - 1; idx >= 0; idx -= 1) {
list = { value: arr[idx], rest: list };
}
return list;
};
const listToArray = (list) => {
const arr = [];
while (list !== null) {
arr.push(list.value);
list = list.rest;
}
return arr;
};
const prepend = (value, rest) => ({ value, rest });
const nth = (list, idx) => {
while (list !== null) {
if (idx === 0) {
return list.value;
}
idx -= 1;
list = list.rest;
}
};
const test = (x) => { console.log(x); return false; };
if (test(1) && test(2)) {
console.log('???');
}