Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
Use worker threads to speed up array search (NodeJS)

Made a function that searches a specific string in a very very large array of strings using Levenshtein Distance. But it's too slow. Takes around 6000-10000ms to complete. How can I make it fast? I expected the function to end in less than 1000ms. Is it possible by using worker threads, cluster or anything else to run the loop in parallel so that I'll get the result in less than a second?

const leven = require('leven');
const veryLargeArray = ['foo bar foo', 'ajskdnasjkd', 'fooo fooo bar fooo', 'bar fooo', /*This array in my actual code has more than 900K strings*/];

function search(str, arr) {
      const results = [];
      for (const item of arr) {
        results.push({ item, distance: leven(str, arr[i]) });
      }
      return results;
}

search('hello', [...veryLargeArray]);
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!