I agree in general, but in this case I think using setTimeout() here would make searching very slow.  It would add 10ms of delay just to determine that we have already calculated the search string for the each node.  If we have 1000 contacts, then that is a lot of extra delay.

I guess I did not consider the synchronous callback that bad since this is not a publicly exposed API call.  Its only used within the app.

Would it be acceptable if I added more comments explaining that the callback will be made synchronously if the value is cached?