in my angularjs app I use esprima.js validation with gulp. And now, esprima throw me error for this two piece of js.
internal/streams/legacy.js:59
throw er; // Unhandled stream error in pipe.
^
Error: Line 38843: Unexpected identifier
This is first piece
var filteredCampaignItems = campaignItems.filter((thing, index, self) => index === self.findIndex((t) => (
t.expectedAdvertisementDisplayCount === thing.expectedAdvertisementDisplayCount && t.smartId === thing.smartId
))
)
and second is filter for sum
app.filter('sumProduct', function() {
return function (input) {
var i = input instanceof Array ? input.length : 0;
var a = arguments.length;
if (i === 0)
return i;
var total = 0;
for(var x of input){
var duration = parseFloat(x.meta_duration);
if(isNaN(duration)){
throw 'filter sumProduct can count only numeric values';
}
total += duration;
}
return total;
}
});
Esprima version is "version": "4.0.0"
and I found for instanbul dependecy that i need to get version "istanbul": "^1.0.0-alpha.2"
, and i manually change to version 1.0.0-alpha.2
and call npm i esprima
. I do this, but same error is throw.
Is there someone who know how to fix this?
I recommend to use BabelJS ( https://babeljs.io/ ).
Babel is a compiler that will convert every "new" features to "old" ES5 code (target-level is configurable, but I guess in most cases ES5 is fine)
They even have an online Tool to try it out live ( https://babeljs.io/repl/ )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.