Answer the question
In order to leave comments, you need to log in
How to optimize the search for the desired phrase in json objects?
Now it will be absurd, and you will write why I need this, BUT there is a web socket through which an array with data arrives every 2 seconds
[
{
"id": 345,
"descripton": "test follow maybe test test"
},
// ... 740 length
]
[
"test test test test test",
"test test test test test",
"test test test test test",
"test test test test test",
"test test test test test",
"test test test test test"
// ... 1mln length
for (object of wsData) {
for (myPhrase of myPhrasesList) {
// Если есть совпадение, вызываю функцию отправки сообщения в тг и отдельный запрос на сайт
}
}
Answer the question
In order to leave comments, you need to log in
// Это должно быть вне обработчика закэшировано
const myPhrasesList = new Set([
"test test test test test",
"test test test test test",
"test test test test test",
"test test test test test",
"test test test test test",
"test test test test test"
// ... 1mln length
]);
for (object of wsData) {
if (!myPhrasesList.has(object.description)) {
continue;
}
this.notification(object, object.description).then()
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question