example/meteor/client/templates/search.js
function(arrayOfSearchResultsArrays) {
  let ids = {};
  let dedupedResults = [];

  _.each(arrayOfSearchResultsArrays, (searchResults) => {
    _.each(searchResults, (item) => {
      if (! ids.hasOwnProperty(item._id)) {
        ids[item._id] = true;

        dedupedResults.push(item);
      }
    });
  });

  return dedupedResults;
}
function(arrayOfSearchResultsArrays) {
  let ids = {};
  let dedupedResults = [];

  _.each(arrayOfSearchResultsArrays, (searchResults) => {
    _.each(searchResults, (item) => {
      if (! ids.hasOwnProperty(item._id)) {
        ids[item._id] = true;

        dedupedResults.push(item);
      }
    });
  });

  return dedupedResults;
}
function ( arrayOfSearchResultsArrays ) { let ids = { } ; let dedupedResults = [ ] ; _ . each ( arrayOfSearchResultsArrays , ( searchResults ) => { _ . each ( searchResults , ( item ) => { if ( ! ids . hasOwnProperty ( item . _id ) ) { ids [ item . _id ] = true ; dedupedResults . push ( item ) ; } } ) ; } ) ; return dedupedResults ; }
When you have two arrays of search results, use this function to deduplicate them
When you have two arrays of search results use this function to deduplicate them