diff --git a/enums.js b/enums.js index 560ae4b..06734fc 100644 --- a/enums.js +++ b/enums.js @@ -6,7 +6,7 @@ }); return target; } - + function Symbol(name, props) { this.name = name; if (props) { @@ -46,10 +46,10 @@ ); } Enum.prototype.contains = function(sym) { - if (! sym instanceof Symbol) return false; + if (!(sym instanceof Symbol)) return false; return this[sym.name] === sym; } exports.Enum = Enum; exports.Symbol = Symbol; }(typeof exports === "undefined" ? this.enums = {} : exports)); -// Explanation of this pattern: http://www.2ality.com/2011/08/universal-modules.html \ No newline at end of file +// Explanation of this pattern: http://www.2ality.com/2011/08/universal-modules.html diff --git a/enums.spec.js b/enums.spec.js index 57d7ba8..59b6646 100644 --- a/enums.spec.js +++ b/enums.spec.js @@ -17,6 +17,7 @@ describe("Enum", function() { var fruit = new enums.Enum("apple", "banana"); expect(color.contains(color.red)).toBeTruthy(); expect(color.contains(fruit.apple)).toBeFalsy(); + expect(color.contains(undefined)).toBeFalsy(); }); });