File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,6 +84,12 @@ Value EmptyConstructor(const CallbackInfo& info) {
8484 return Boolean::New (env, object.IsEmpty ());
8585}
8686
87+ Value ConstructorFromObject (const CallbackInfo& info) {
88+ auto env = info.Env ();
89+ Object object = info[0 ].As <Object>();
90+ return Object (env, object);
91+ }
92+
8793Array GetPropertyNames (const CallbackInfo& info) {
8894 Object obj = info[0 ].As <Object>();
8995 Array arr = obj.GetPropertyNames ();
@@ -253,6 +259,7 @@ Object InitObject(Env env) {
253259 Object exports = Object::New (env);
254260
255261 exports[" emptyConstructor" ] = Function::New (env, EmptyConstructor);
262+ exports[" constructorFromObject" ] = Function::New (env, ConstructorFromObject);
256263
257264 exports[" GetPropertyNames" ] = Function::New (env, GetPropertyNames);
258265 exports[" defineProperties" ] = Function::New (env, DefineProperties);
Original file line number Diff line number Diff line change @@ -107,6 +107,12 @@ function test(binding) {
107107 assert . strictEqual ( binding . object . emptyConstructor ( false ) , false ) ;
108108 }
109109
110+ {
111+ const expected = { 'one' : 1 , 'two' : 2 , 'three' : 3 } ;
112+ const actual = binding . object . constructorFromObject ( expected ) ;
113+ assert . deepStrictEqual ( actual , expected ) ;
114+ }
115+
110116 {
111117 const obj = { } ;
112118 const testSym = Symbol ( ) ;
You can’t perform that action at this time.
0 commit comments