sindresorhus / electron-store

Simple data persistence for your Electron app or module - Save and load user preferences, app state, cache, etc
MIT License
4.61k stars 150 forks source link

Wrong prototype of changes object #214

Closed knaos closed 2 years ago

knaos commented 2 years ago

"electron-store": "8.0.1" OS: Windows 10

When adding a onDidAnyChange callback, the arguments for newValue and oldValue are objects but they don't inherit from Object.prototype. When I run Object.getPrototypeOf(newValue) I get null.

This effectively is misleading when trying to use methods from the Object prototype, like Object.prototype.hasOwnProperty(key).

I think that the arguments for the new and old values should inherit from the Object.prototype()

sindresorhus commented 2 years ago

Not having a prototype is intentional. All objects returned by this package don't for security reasons. It's a generally recommended practice not to use Object.prototype.hasOwnProperty as you can never always know where objects are coming from.

https://github.com/tc39/proposal-accessible-object-hasownproperty

knaos commented 2 years ago

I understand. Thanks! Closing this issue.