File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,12 @@ Value CreateObjectUsingMagic(const CallbackInfo& info) {
228228 return obj;
229229}
230230
231+ Value InstanceOf (const CallbackInfo& info) {
232+ Object obj = info[0 ].As <Object>();
233+ Function constructor = info[1 ].As <Function>();
234+ return Boolean::New (info.Env (), obj.InstanceOf (constructor));
235+ }
236+
231237Object InitObject (Env env) {
232238 Object exports = Object::New (env);
233239
@@ -265,5 +271,7 @@ Object InitObject(Env env) {
265271 exports[" addFinalizer" ] = Function::New (env, AddFinalizer);
266272 exports[" addFinalizerWithHint" ] = Function::New (env, AddFinalizerWithHint);
267273
274+ exports[" instanceOf" ] = Function::New (env, InstanceOf);
275+
268276 return exports;
269277}
Original file line number Diff line number Diff line change @@ -137,4 +137,13 @@ function test(binding) {
137137 circular2 : magicObject
138138 } ) ;
139139 }
140+
141+ {
142+ function Ctor ( ) { } ;
143+
144+ assert . strictEqual ( binding . object . instanceOf ( new Ctor ( ) , Ctor ) , true ) ;
145+ assert . strictEqual ( binding . object . instanceOf ( new Ctor ( ) , Object ) , true ) ;
146+ assert . strictEqual ( binding . object . instanceOf ( { } , Ctor ) , false ) ;
147+ assert . strictEqual ( binding . object . instanceOf ( null , Ctor ) , false ) ;
148+ }
140149}
You can’t perform that action at this time.
0 commit comments