Transform a stream or array into a lookup object