const ItemComponent = props => (
<div>
<p>{props.title}</p>
</div>
);
...
<Carousel
items={items}
ItemComponent={ItemComponent}
/>
const getNum = () => new Promise(r => setTimeout(r, 1000, Math.random() * 100 | 0));
(async () => {
console.time('xxx');
const [ result1, result2 ] = [ await getNum(), await getNum() ];
console.log(result1, result2);
console.timeEnd('xxx');
})();
(async () => {
console.time('yyy');
const [ result1, result2 ] = await Promise.all([ getNum(), getNum() ]);
console.log(result1, result2);
console.timeEnd('yyy');
})();
$('table').on('change', 'select', ({ target: t }) => {
const isNone = t.value === 'none';
$(t)
.closest('td')
[isNone ? 'nextAll' : 'next']()
.find('select')
.prop('disabled', isNone)
.val((i, val) => isNone ? 'none' : val);
});
document.querySelector('table').addEventListener('change', ({ target: t }) => {
if (t.tagName === 'SELECT') {
const isNone = t.value === 'none';
const { cellIndex: i, parentNode: { children } } = t.closest('td');
[...children].slice(i + 1, isNone ? undefined : i + 2).forEach(n => {
const select = n.querySelector('select');
select.disabled = isNone;
select.value = isNone ? 'none' : select.value;
});
}
});
this.onWheel.bind(this) !== this.onWheel.bind(this) // true
<button id="button-1"
$('#botton-1').on('dblclick',
$('#example thead tr:eq(1) th').slice(2).each(... дальше всё как было
не проканало, то есть визуально все как надо но по факту поиск из фильтра стал работать не в той колонке
table.column(i)
, а table.column(i + 2)
. Или не полагаться на передаваемый индекс, а вычислять его самостоятельно, что-то вроде const index = $(this).closest('th').index()
. const result = obj1.filter(n => !arr1.includes(n.id));
const result = obj1.filter(function(n) {
return !this.has(n.id);
}, new Set(arr1));
const result = Object.values(arr1.reduce(
(acc, n) => (delete acc[n], acc),
obj1.reduce((acc, n) => (acc[n.id] = n, acc), {})
));
const result = [...arr1.reduce(
(acc, n) => (acc.delete(n), acc),
new Map(obj1.map(n => [ n.id, n ]))
).values()];
const count = arr.reduce((acc, n) => (acc[n.revitid] = (acc[n.revitid] || 0) + 1, acc), {});
const unique = Object.entries(count).filter(n => n[1] === 1).map(n => n[0]);
const newArr = arr.filter(n => unique.includes(n.revitid));
const duplicate = arr.reduce((acc, n) => (acc[n.revitid] = acc.hasOwnProperty(n.revitid), acc), {});
const newArr = arr.filter(n => !duplicate[n.revitid]);
const newArr = arr.filter(function(n) {
return !this.get(n.revitid);
}, arr.reduce((acc, { revitid: n }) => acc.set(n, acc.has(n)), new Map));
const newArr = arr.filter((n, i, a) => a.filter(m => m.revitid === n.revitid).length === 1);
const newArr = Object
.values(arr.reduce((acc, n) => (acc[n.revitid] = acc[n.revitid] ? 1 : n, acc), {}))
.filter(n => n !== 1);
const newArr = Object
.values(arr.reduce((acc, n) => ((acc[n.revitid] = acc[n.revitid] || []).push(n), acc), {}))
.flatMap(n => n.length === 1 ? n : []);
const getImageSizes = src => new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => resolve({ width: img.width, height: img.height });
img.onerror = reject;
img.src = src;
});
getImageSizes(здесь путь к вашей картинке).then(sizes => {
...
});
map.events.add('boundschange', function(e) {
placemark.geometry.setCoordinates(e.get('newCenter'));
});
const chunks = (arr, chunkSize) =>
arr.reduce((acc, n, i) => (
(i % chunkSize) || acc.push([]),
acc[acc.length - 1].push(n),
acc
), []);
const data = [...Array(12).keys()];
const chunkSize = 2;
const html = chunks(data, chunkSize)
.map(n => `<div>${n.map(m => `<div>${m}</div>`).join('')}</div>`)
.join('');