Permalink
Browse files

Support the different RegEx type in Node 0.6

In Node.js 0.6, `typeof /foo/` returns "function", but
`foo instanceof RegExp` returns `true`. So this change works for both
versions.
  • Loading branch information...
jhs committed Dec 6, 2011
1 parent f8a5268 commit 00a07b6e27d53584fd0cad43dae20c39e4f7570e
Showing with 1 addition and 2 deletions.
  1. +1 −2 lib/Tokenizer.js
View
@@ -89,8 +89,7 @@ Tokenizer.prototype.addRule = function addRule(regex, type) {
if(!type) {
return this.addRule(regex[0], regex[1]);
}
- assert.equal(typeof regex, 'function');
- //assert.ok(regex instanceof RegExp);
+ assert.ok((regex instanceof RegExp) || (typeof regex === 'function'))
assert.equal(typeof type, 'string');
this._regexes.push({regex:regex,type:type});
};

0 comments on commit 00a07b6

Please sign in to comment.