From 8a3d71b5969889797c15ce16dbb5a210928a2264 Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Mon, 1 Sep 2014 20:03:22 -0700 Subject: [PATCH] throw error for invalid strings --- lib/opcode.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/opcode.js b/lib/opcode.js index 04c3ccf..c53bdc8 100644 --- a/lib/opcode.js +++ b/lib/opcode.js @@ -28,7 +28,10 @@ Opcode.prototype.toNumber = function() { }; Opcode.prototype.fromString = function(str) { - this.num = Opcode.map[str]; + var num = Opcode.map[str]; + if (typeof num === 'undefined') + throw new Error('Invalid opcodestr'); + this.num = num; return this; };