Skip to content

Commit

Permalink
Add Native.is_a? to wrap instanceof
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Sep 30, 2013
1 parent 59fde73 commit ce5cd7e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions corelib/native.rb
Expand Up @@ -141,6 +141,17 @@ def length
alias to_ary to_a
end

def self.is_a?(object, klass)
%x{
try {
return #{object} instanceof #{klass};
}
catch (e) {
return false;
}
}
end

def self.try_convert(value)
%x{
if (#{native?(value)}) {
Expand Down

0 comments on commit ce5cd7e

Please sign in to comment.