An utility function similar to that in underscore or lo-dash