Scanning directories and caching paths to an array
I have to ask why you would want to find a file anywhere on the filesystem. That seems like a pretty odd requirement. Most apps (take node module loading for example) check a limited number of folders which can be done very quickly.

To answer your questions:


the OS does not do this kind of caching.
No, I wouldn't consider this safe. For two reasons. There are many other names that could match. For example video_file_1.txt, file_1.txt.old or some_path/file_1.txt/cat.jpg.  I would check against the basename something like

function basename(path) {
   return path.match(/[^\\\/]+$/)[0];
}
const matches = cache.filter(element =&gt; basename(element) == filename) 

Someone already answered this in the comments. It is really just an artifact of attempting to handle windows and unix paths consistently. 


Also if retrieval efficiency is important then I would store the data as a hash not an array, i.e:

let cache = {};

let paths = walkdir(searchDir, options, (path) =&gt; {
  const name = basename(path);
  if (!cache[basename])
    cache[basename] = [];  
  cache[basename].push(path)
});


Then finding an element is a simple matter of:

findItem (cache) {
  let filename = 'file_1.txt';
  const matches = cache[filename];
  console.log(matches);
}


Note that, since you are on Windows, you should also consider case-insensitivity of filenames.