другое возможное решение:
public enum @base
{
x,
y,
z
}
public enum consume
{
x = @base.x,
y = @base.y,
z = @base.z,
a,b,c
}
// TODO: Add a unit-test to check that if @base and consume are aligned
HTH
Нет, это невозможно изменить в процессе деструктуризации - этот ответ объясняет почему.
Гораздо проще проверить, используя some
вместо includes
:
const words = ['word1', 'word2', 'word3']
const texts = [{
name: 'blah',
description: 'word4'
},
{
name: 'blah2',
description: 'word1'
},
{
name: 'blah3',
description: 'word5'
}
]
console.log(
texts.some(
({
description
}) => words.some(word => word.toLowerCase == description.toLowerCase())
)
)
JSON.stringify
для преобразования ваших объектов в строки .toLowerCase
к полученным строкам так, чтобы все (включая все значения) становится строчными JSON.parse
Array.some
и [ 115]
const words = ['WORD1', 'WORD2', 'WORD3'];
const texts = [
{name: 'blah', description: 'word4'},
{name: 'blah2', description: 'word1'},
{name: 'blah3', description: 'word5'}
];
const lower = x => JSON.parse(JSON.stringify(x).toLowerCase());
const [lowerWords, lowerTexts] = [words, texts].map(lower);
console.log(
lowerTexts.some(
({ description }) => lowerWords.includes(description)
)
)