developit / developit/workerize
non-enumerable object properties are lost after passing an object to workerize.
- 主要言語
- JavaScript
- スター
- 4.4k
- フォーク
- 87
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
Start with the workerize-loader example and reproduce the reported difference between the Firebase objects and the filtered result. Inspect the worker call boundary and the README to determine whether preserving non-enumerable properties is intended. Done means either retaining the id properties across the call or documenting the observed behavior clearly.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- web-dev
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100