Description
For My example below:
var Parallel = require('paralleljs');
var _ = require('lodash');
let data = {
"a":{"id":1},
"b":{"id":2},
"c":{"id":3},
"d":{"id":4}
};
for(let i in data){
const p = new Parallel(data[i]);
p.spawn(test)
.then(function (data) {
console.log("iv",_.capitalize('hello'))
const documentProcessingData = ["DATA_MODEL_1","DATA_MODEL_2", "DATA_MODEL_3"];
documentProcessingData.forEach((curr,index)=>{
const aiProjectProcessing = new Parallel(curr);
aiProjectProcessing.spawn(dmdPrcosessing) .then(function (data) {
console.log("Finished", data);
})
})
});
}
function test(dmd){
console.log("hello",dmd);
console.log("ii", .capitalize('hello')) //can't resolve "" lodash here
return dmd
}
function dmdPrcosessing(val){
console.log("iii", _.capitalize('hello')) //can't resolve "_" lodash here
var start = new Date().getTime();
var end = start;
var waitingTime = (Math.random() * (10000 - 5000) + 5000);
console.log("waitingTime ",waitingTime);
while(end < start + waitingTime){
end = new Date().getTime();
}
return val;
}
I get the following error:
undefined:3
console.log("ii", _.capitalize('hello'))
^
ReferenceError: _ is not defined
at dmdPrcosessing (eval at (D:\Workspace\Speed Measurement Comparision\node_modules\paralleljs\lib\eval.js:7:5), :3:24)
at process.eval (eval at (D:\Workspace\Speed Measurement Comparision\node_modules\paralleljs\lib\eval.js:7:5), :13:3)
at process.emit (events.js:314:20)
at emit (internal/child_process.js:877:12)
at processTicksAndRejections (internal/process/task_queues.js:85:21)
Is there a better way to do this?