javascript - Using Node.js file system is it smarter to run through 80 files looking for a property than it is to run through conditions in one file? -
Let me explain: I have a node. I am building a JS project, which needs to be examined whether the dates fall within a match or category. If there is a match, then I have to store the reference of the file's path on the server. Of these, 80 files are those configurations.
I can write a huge position in that function that can run through dates and check dates. It will be faster, I'm sure. The real question is, it is clever to charge every charge file on its own date (there is a calculation based on date of date which must be passed to the config file), then loop through files, each one required Is it to find the property that holds the date, check it, or to store the file path?
The necessary approach will be a lot less code, and it will be cleaner, but I'm thinking if I will take a big demonstration hit, is it better to just write a huge list of conditions?
Sorry if this is not clear. Let me know that I need to include anything in clarifying the question.
The date is a count based on a date that must be passed in the config file < / P>
Then do not even count the results in the config file, but store it in memory. / P>
On startup, to run all 80 files (in parallel?), Collect dates and calculate related. Store the results either in an array
On each request, find a loop (a huge hand written not!) To find the date, and use the file path associated with it.