// The worker
import intersection from 'lodash/intersection';
export const filterCompaniesByTypes = (companies, typesToFilerBy) => {
return companies.filter(({ types, id }) => {
// typeof id === 'undefined' // true
return intersection(types, typesToFilerBy).length > 0;
});
};
In the given example the getCompaniesFromFirebase() function returns an array of objects. Each object has some properties, inluding the id property that is non-enumerable.
After executing the filterCompaniesByTypes() function (which is a web worker function) I receive a filtered array. All id properties are gone.
if it's the desired behaviour (or an unpleasant, but expected, side-effect) not a bug, then it would be good to mention it in the readme.
Here's a real life example:
In the given example the
getCompaniesFromFirebase()
function returns an array of objects. Each object has some properties, inluding theid
property that is non-enumerable.After executing the
filterCompaniesByTypes()
function (which is a web worker function) I receive a filtered array. Allid
properties are gone.if it's the desired behaviour (or an unpleasant, but expected, side-effect) not a bug, then it would be good to mention it in the readme.