From 192d16f4d9535365a36f0f0518fb452f7cf493df Mon Sep 17 00:00:00 2001 From: Marvin Roger Date: Tue, 11 Apr 2017 10:54:51 +0200 Subject: [PATCH] :sparkles: Allow ES6 classes --- scientist.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scientist.js b/scientist.js index 037d021..689d8ed 100644 --- a/scientist.js +++ b/scientist.js @@ -35,8 +35,7 @@ exports.create = function(/* constructor, ...constructorArgs */) { var machine; if (constructor.prototype) { - machine = Object.create(constructor.prototype); - machine.constructor.apply(machine, constructorArgs); + machine = new (Function.prototype.bind.apply(constructor, [null].concat(constructorArgs))); } else if (constructor.init) { machine = constructor; }