-
-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Today I had a hard time debugging when trying to find out why a library I use doesn't work as expected.
The base root cause is by this library which checks if an object is a base-object.
It tries to do so by checking the prototype of new Object().
As I found out today, the prototype of a new object is not always the same. This becomes evident when running your code in a NodeJS vm.
const vm = require('vm');
global.MongoObject = require('mongo-object').default;
console.log(vm.runInNewContext(`MongoObject.isBasicObject({})`, { MongoObject: MongoObject }));
console.log(vm.runInThisContext(`MongoObject.isBasicObject({})`));
console.log(MongoObject.isBasicObject({}));The code produces the following output:
false
true
truePlease find a way to check for plain objects without using the constructor or note at a place that this package is not stable when using in more than one NodeJS contexts.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels