mirror of https://github.com/pelias/api.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
966 B
33 lines
966 B
const _ = require('lodash'); |
|
|
|
// "arguments" is only available in long-form function declarations, cannot be shortened to fat arrow syntax |
|
// potential improvement: inject set operator to allow for any/all functionality |
|
module.exports = { |
|
all: function() { |
|
// save off property names for future reference |
|
const properties = _.values(arguments); |
|
|
|
// return true if ALL of the supplied properties are in clean.parsed_text |
|
return request => _.isEmpty( |
|
_.difference( |
|
_.values(properties), |
|
_.keys(_.get(request, ['clean', 'parsed_text'], {})) |
|
) |
|
); |
|
|
|
}, |
|
any: function() { |
|
// save off property names for future reference |
|
const properties = _.values(arguments); |
|
|
|
// return true if ANY of the supplied properties are in clean.parsed_text |
|
return request => !_.isEmpty( |
|
_.intersection( |
|
_.values(properties), |
|
_.keys(_.get(request, ['clean', 'parsed_text'], {})) |
|
) |
|
); |
|
|
|
} |
|
|
|
};
|
|
|