Home Manual Reference Source Test Repository

lib/filter/metadata.js

  1. import _ from 'lodash';
  2.  
  3. /**
  4. * Metadata filter. Checks if a file.data object matches all the configured
  5. * filter options.
  6. * @example
  7. * let filterConfig = {
  8. * draft: true
  9. * };
  10. * file.data = {
  11. * title: 'foo',
  12. * draft: true
  13. * };
  14. * metadataFilter(filterConfig, file); // true
  15. * @param {File} file File we're checking.
  16. * @param {Object} filterConfig Filter config object.
  17. * @return {boolean} If the File matches the filterConfig object.
  18. */
  19. export default function metadataFilter(file, filterConfig) {
  20. return _.isMatch(file.data, filterConfig);
  21. }