shouldUpdate =
!shallowEqual(prevProps, nextProps) ||
!shallowEqual(inst.state, nextState);
const key = 'prop';
const val = 1;
const result = array.flatMap(n => n.filter(m => m[key] === val));
// или
const result = array.reduce((acc, n) => (
n.forEach(m => m[key] === val && acc.push(m)),
acc
), []);
// или
const result = [];
for (const n of [].concat(...array)) {
if (n[key] === val) {
result[result.length] = n;
}
}
const group = (arr, key) =>
arr.reduce((acc, n) => {
const k = n[key];
(acc[k] = acc[k] || []).push(n);
return acc;
}, {});
const result = Object.values(group(array, 'prop'));
function group(data, key, val = n => n) {
const getKey = key instanceof Function ? key : n => n[key];
const getVal = val instanceof Function ? val : n => n[val];
const grouped = {};
for (const n of data) {
(grouped[getKey(n)] ??= []).push(getVal(n));
}
return grouped;
}
const groupedBySign = group([ 0, 1, 2, 3, -10, -20, -30, 0 ], Math.sign);
const groupedByParity = group(Array(10).keys(), n => [ 'чётные', 'нечётные' ][n & 1]);
const chars = group(
'ABC123?!+',
n =>
n.toLowerCase() !== n.toUpperCase() ? 'буква' :
Number.isInteger(+n) ? 'цифра' :
'другое'
);
<input name="xxx" value="69">
<input name="xxx" value="187">
<input name="xxx" value="666">
<input name="yyy" value="0">
const values = group(document.querySelectorAll('input'), 'name', 'value');
const result = Object.values(Object.groupBy(array, n => n.prop));
upload_url
c полем file, содержащим файл в формате multipart/form-dataserver
, photo
и hash
const obj = array.reduce((acc, n, i) => (
acc[`filter${i + 1}`] = { ...baseFilter, prop: n },
acc
), {});
const obj = {};
for (const [ i, n ] of array.entries()) {
(obj['filter' + (-~i)] = Object.assign({}, baseFilter)).prop = n;
}
const obj = {};
for (let i = 0; i < array.length;) {
const subobj = { prop: array[i] };
for (const k in baseFilter) {
subobj[k] = baseFilter[k];
}
obj['filter'.concat(++i)] = subobj;
}
const res = items.filter(o => dictionary.some(v => v.code == 'seller' && v.id == o.role));
const names = {
nullable: "inn,kpp,ogrn,organizationName,phone,email,webAddress,address,accreditationState,description"
.split(","),
dates: "ogrnIssueDate,accreditationDate,accreditationEndDate"
.split(","),
};
const data = {};
for(let i = 0; i < names.nullable.length; i++) {
const prop = names.nullable[i];
data[prop] = fields.hasOwnProperty(prop) ? fields[prop] : null;
}
for(let i = 0; i < names.dates.length; i++) {
const prop = names.dates[i];
data[prop] = fields.hasOwnProperty(prop) ? convertToDtoDate(fields[prop]) : null;
}
Shift + Alt + Down или Shift + Alt + Up
[
{
"key": "ctrl+shift+u",
"command": "editor.action.transformToUppercase",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+l",
"command": "editor.action.transformToLowercase",
"when": "editorTextFocus"
}
]
The declaration syntax for a DECIMAL column is DECIMAL(M,D). The ranges of values for the arguments are as follows:
M is the maximum number of digits (the precision). It has a range of 1 to 65.
D is the number of digits to the right of the decimal point (the scale). It has a range of 0 to 30 and must be no larger than M.