mirror of https://github.com/pelias/api.git
Stephen Hess
7 years ago
5 changed files with 48 additions and 37 deletions
@ -0,0 +1,17 @@
|
||||
const _ = require('lodash'); |
||||
|
||||
// return true if any setup parameter is a key of request.clean.parsed_text
|
||||
// "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 = function() { |
||||
// save off requested properties since arguments can't be referenced later
|
||||
const properties = _.values(arguments); |
||||
|
||||
return (request, response) => !_.isEmpty( |
||||
_.intersection( |
||||
properties, |
||||
_.keys(_.get(request, ['clean', 'parsed_text'], {})) |
||||
) |
||||
); |
||||
|
||||
}; |
@ -1,13 +0,0 @@
|
||||
const _ = require('lodash'); |
||||
|
||||
// returns a function that returns true if any result.layer is in any of the
|
||||
// supplied layers using array intersection
|
||||
|
||||
// example usage: determining if the response contains only admin results
|
||||
|
||||
module.exports = (property) => { |
||||
return (request, response) => { |
||||
return _.has(request, ['clean', 'parsed_text', property]); |
||||
}; |
||||
|
||||
}; |
Loading…
Reference in new issue