get searchtest() {
const search = this.state.search.toLowerCase().trim();
return search
? searchtest.filter(n => Object.values(n).some(m => m.toLowerCase().includes(search)))
: searchtest;
}
{this.searchtest.map((kef, i, a) => ( <div style={style}> <div key={kef.name} data-id={kef.name}> name: {kef.name} </div> <div key={kef.id} data-id={kef.id}> id: {kef.id} </div> </div> ))}
{this.searchtest.map(n => (
<div key={n.id}>
<div>name: {n.name}</div>
<div>id: {n.id}</div>
</div>
))}
const order = Object.fromEntries(gameTypeOrder.map((n, i) => [ n, i ]));
res.sort((a, b) => order[a.game_status] - order[b.game_status]);
const sortedRes = res
.reduce((acc, n) => (acc[order[n.game_status]].push(n), acc), gameTypeOrder.map(() => []))
.flat();
// или
const sorted = (arr, key) => arr
.map(n => [ n, key(n) ])
.sort((a, b) => a[1] - b[1])
.map(n => n[0]);
const sortedRes = sorted(res, n => order[n.game_status]);
const Promise = require('bluebird');
let results = await Promise.map(filteredMatches, v => handler(v.CI), { concurrency: 10 });
const SKILLS = {
sport: [ 'running', 'squats', 'snowboarding' ],
music: [ 'guitar', 'drums' ],
};
const filterBySkill = (people, filter) =>
people.filter(({ skills }) =>
skills.every(n => filter.some(m => SKILLS[m].includes(n))) &&
filter.every(n => skills.some(m => SKILLS[n].includes(m)))
);
const result = Object.values(arr.reduce((acc, n) => (
(acc[n.ID] = acc[n.ID] || { ID: n.ID })[n.FIELD] = n.VALUE,
acc
), {}));