question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ES6 Arrow functions

See original GitHub issue

Hello,

My current project is stuck at ES5. I’m still using gulp 3.9 for the minification and ‘uglification’ of my JS code to generate the production files.

Because of this, I can’t minify/uglify jquery.flot.js. On line 976 there is a function called ‘addEventHandler’ which uses ES6 arrow functions.

Is it possible to change (back) the ES6 arrow function to ES5 anonymous functions…?

Like this:

eventList.sort(function(a, b) { return b.priority - a.priority });

and

eventList.forEach(function(eventData) {
     eventData.eventHolder.unbind(eventData.event, eventData.handler);
     eventData.eventHolder.bind(eventData.event, eventData.handler);
});

Instead of this:

eventList.sort((a, b) => b.priority - a.priority );

and

eventList.forEach( eventData => {
     eventData.eventHolder.unbind(eventData.event, eventData.handler);
     eventData.eventHolder.bind(eventData.event, eventData.handler);
});

This way, I’m able to uglify/minify the code.

Thank you in advance!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
andrewdove1commented, Apr 11, 2019

In the npm package there is a dist/es5 folder containing the code you need

0reactions
Paulskycommented, Apr 12, 2019

I completely understand this! Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Arrow function expressions - JavaScript - MDN Web Docs
Arrow functions can have either a concise body or the usual block body. In a concise body, only a single expression is specified,...
Read more >
JavaScript Arrow Function - W3Schools
JavaScript Arrow Function · Before Arrow: · With Arrow Function: · Arrow Functions Return Value by Default: · Arrow Function With Parameters: ·...
Read more >
Arrow functions, the basics - The Modern JavaScript Tutorial
There's another very simple and concise syntax for creating functions, that's often better than Function Expressions. It's called “arrow ...
Read more >
A Gentle Introduction to JavaScript Arrow Function
ES6 arrow functions provide you with an alternative way to write a shorter syntax compared to the function expression. ... In this example,...
Read more >
Arrow Functions in JavaScript: Fat & Concise Syntax - SitePoint
The arrow function inside the .map() function develops over a series of statements, at the end of which it returns an object. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found