From 0cafd3c375175f343ada059011d82b8c71a52d03 Mon Sep 17 00:00:00 2001 From: Marvin Roger Date: Thu, 13 Apr 2017 12:31:16 +0200 Subject: [PATCH] :sparkles: Allow ES2015 classes --- resource.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resource.js b/resource.js index 083fd62..e874e50 100644 --- a/resource.js +++ b/resource.js @@ -345,8 +345,7 @@ module.exports = function(/* constructor, ...constructorArgs */) { var obj; if (constructor.prototype) { - obj = Object.create(constructor.prototype); - obj.constructor.apply(obj, constructorArgs); + obj = new (Function.prototype.bind.apply(constructor, [null].concat(constructorArgs))); } else if (constructor.init) { obj = constructor; }