How can I efficiently filter an array of strings matching a sequence of characters, such that characters may be matched anywhere in the string but in the order they are used?

It's a feature commonly seen in editors and IDEs to quickly filter filenames.

See an illustration of the filter in action in the attached image link.

This is not a duplicate of JavaScript autocomplete without external library, because one of the requirements here is for user input "Caz" to match "Cangzhou" which is explained in the answer to this question, but not in the answers to other questions.