From 3208ca2a44efc29d308c47ce892ae64998c2a5b5 Mon Sep 17 00:00:00 2001 From: Yemel Jardi Date: Mon, 1 Dec 2014 16:02:06 -0300 Subject: [PATCH] Allow creating instance without new --- lib/unit.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/unit.js b/lib/unit.js index 983c818..f2ca33c 100644 --- a/lib/unit.js +++ b/lib/unit.js @@ -23,6 +23,10 @@ */ function Unit(amount, code) { + if (!(this instanceof Unit)) { + return new Unit(amount, code); + } + this._value = this._from(amount, code); var self = this;