@paulmillr Based on the example you gave, couldn't the first arg be any matcher or array? Why are you testing only for function here?

Maybe it would be better to change the arg order so criteria is always first.