lib/endpoints/matchEndpoint.js
function matchEndpoint (endpoints) {
  return ({ type, payload, meta }) => endpoints
    .find((endpoint) =>
      matchId(endpoint, { type, payload }) &&
      matchType(endpoint, { type, payload }) &&
      matchScope(endpoint, { type, payload }) &&
      matchAction(endpoint, { type, payload }) &&
      matchParams(endpoint, { type, payload }) &&
      matchFilters(endpoint, { type, payload, meta }))
}
function matchEndpoint (endpoints) {
  return ({ type, payload, meta }) => endpoints
    .find((endpoint) =>
      matchId(endpoint, { type, payload }) &&
      matchType(endpoint, { type, payload }) &&
      matchScope(endpoint, { type, payload }) &&
      matchAction(endpoint, { type, payload }) &&
      matchParams(endpoint, { type, payload }) &&
      matchFilters(endpoint, { type, payload, meta }))
}
Return the first matching endpoint from an array of endpoints that has
already been sortert with higher specificity first. Type should match before
scope, which should match before action, but the order here is taken care of
by the required sorting.

@param {Object[]} endpoints - Array of endpoint objects
@param {Object} action - Action object to match agains
@returns {Object} Matching endpoint