SoftwareGuy / NodeListServer

Node List Server is a multi-purpose server list system. NodeJS powered and supports Docker.
Other
92 stars 33 forks source link

Update listServer.js #24

Closed yayza closed 2 years ago

yayza commented 2 years ago

Cleaned up apiUpdateServerInList function a little by changing the conditionals to a forEach loop.

yayza commented 2 years ago

Looks good, although at line 287 you've got brackets around updatedServer. Can you explain what's happening there? Is that loading it into a pointer for the Object stuff underneath to then do direct modifications to it?

It's just ES6 syntactic sugar. The brackets are unpacking/destructuring the the filter method's returning array (in this case just a single element) into the variable updatedServer. It's still a copy and still needs to get pushed back into the remaining stack of servers like it was done before. I was thinking of mutating the original array, but I don't know if that will introduce bad side-effects.

I updated it again for better readability (and to skip a value update if it never changed).

SoftwareGuy commented 2 years ago

Ah, so it's a ES6 thing. I'm not familiar with ES6 and well, I just know enough basics to make things work. 😅

Looks good to me, I'll merge it in. Thanks for the contribution!