parallel-js/parallel.js

global.env is undefined (Node and Typescript)

gbenattar opened this issue · 3 comments

Hi,
I am using node and Typescript and when sharing data accross thread using global.env, the property "env" is undefined.

Am I missing something?

$> node --version
v9.3.0
$>
paralleljs": "^0.2.1"
let iterArray : number [] = Array.from(Array(40).keys()); 
let p = new Parallel(iterArray, {
    env : {
        test: "test"
    }
});

let computeIter = function (iter) {  
    //@ts-ignore
    console.log(global.env.test);
    return iter;
};

p.map(computeIter).then(function () {
    console.log(arguments);
});

TypeError: Cannot read property 'test' of undefined

I was facing the same issue. After I dived in the source code and read the post by @adambom , I believe this issue should have been resolved.
So I checked @adambom 's code and I found out that his code is different from my code in node_modules/paralleljs.
I tried to npm update, uninstall & reinstall, but my code is still different from the latest code in github.
I gave up. Now I just downloaded the code from github and copied it into node_modules/paralleljs.
This issues is resolved. Now console.log(global.env) has shown some data.

Perhaps the issue is in npm not be able to pull the latest code from github.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.