Permalink
Browse files

Added nested matching for classes (requires constructor.super_,) Late…

…st revision of node supports this.
  • Loading branch information...
1 parent e840e26 commit 5f817964fa2d84009f94c448fea25d544bcd774c @jfd committed Dec 8, 2009
Showing with 6 additions and 2 deletions.
  1. +6 −2 match.js
View
@@ -70,8 +70,12 @@ var Match = (function() {
// Function (class constructor) resolver.
Function: function(ctor) {
return function(value) {
- if(!value || value.constructor !== ctor) throw NO_MATCH;
- return [value];
+ var c = value !== undefined ? value.constructor : undefined;
+ if(c) {
+ if(c === ctor) return [value];
+ while((c = c.super_)) if(c === ctor) return [value];
+ }
+ throw NO_MATCH;
}
},

0 comments on commit 5f81796

Please sign in to comment.