babel/lib/6to5/templates/apply-constructor.js
Ingvar Stepanyan 60713f0e5f Speed up constructor spreads.
Replace slow .bind with manual .create+.apply.
Gives up to 19x speed up depending on browser.

http://jsperf.com/apply-constructor
2014-11-22 14:22:50 +02:00

6 lines
147 B
JavaScript

(function (Constructor, args) {
var instance = Object.create(Constructor.prototype);
Constructor.apply(instance, args);
return instance;
});