Thursday, 21 November 2019

How do you avoid blocking the event loop?

Let's say you have to sort a large array of users. How do you insure that it won't block the event loop used to respond to HTTP requests?function sortUsersByAge(users) { users.sort(function(a, b) { return a.age < b.age ? -1 : 1 }) } Do you have to send requests for sorting the arrays to a new Node.js server and then asynchronously wait for the result? Or is there a better way? What are some solutions including the less optimal ones?

Submitted November 21, 2019 at 09:02PM by jesusscript

No comments:

Post a Comment