mics icon indicating copy to clipboard operation
mics copied to clipboard

README suggests classes can be constructed using `new` but this does not appear to be the case.

Open yyny opened this issue 7 years ago • 2 comments

As shown and stated here.

Relevant example shown in README:

var looker = new Looker()     // > A looker is born!
looker.look()                 // > Looking good!
looker instanceof Looker      // true

Specifically, line 45 of index.js contains code which eventually returns an instance of (...args) => new Class(...args) (which has been like this for over 6 months ago), which cannot be called as a constructor (Since it is an arrow function).

new (() => {}); //=> Uncaught TypeError: (intermediate value) is not a constructor
                //=>    at <anonymous>:1:1

Using function(...args) { return new Class(...args) } instead would make the code work (without compilation) for platforms that disallow arrow functions as constructors (As required by ES6).

yyny avatar Oct 29 '17 21:10 yyny

Yeah this is a bummer. I really like this library, powerful tool in my toolbelt. But the opinionated decision of trying to work around usingnew gets me down. Honestly I prefer new. It's easier to read when something is being instantiated in the middle of a few hundred lines of code.

mindfullsilence avatar Nov 07 '17 07:11 mindfullsilence

Hi guys, I see what the problem is and will look at this soon. Sorry for the late response but this is Open Source and I do it in my spare time.

Download avatar Mar 23 '18 17:03 Download