developit / developit/workerize
non-enumerable object properties are lost after passing an object to workerize.
- Linguagem predominante
- JavaScript
- Estrelas
- 4.4k
- Forks
- 87
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
Here's a real life example:
``` js
// The main thread
import Worker from 'workerize-loader!./workers';
import getCompaniesFromFirebase from './getCompaniesFromFirebase';
const worker = Worker();
const {
filterCompaniesByTypes
// Other modules
} = worker;
(async () => {
const companies = await getCompaniesFromFirebase();
// typeof companies[0].id === "string" // true
const companiesFiltered = await filterCompaniesByTypes(companies, ['company-type-1', 'company-type-2']);
// typeof companiesFiltered[0].id === "string" // false
// typeof companiesFiltered[0].id === "undefined" // true
})();
```
``` js
// 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.
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
Comece pelo exemplo de workerize-loader e reproduza a diferença relatada entre os objetos do Firebase e o resultado filtrado. Inspecione o limite da chamada do worker e o README para determinar se a preservação de propriedades não enumeráveis é intencional. Considera-se concluído se as propriedades id forem mantidas durante a chamada ou se o comportamento observado for documentado claramente.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- javascript
- Domínio
- web-dev
- Tipo de issue
- Bug
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100