dfahlander / typeson-registry

The type registry for typeson
MIT License
6 stars 5 forks source link

Magic for types to short-circuit `isPlainObject` checks #5

Closed brettz9 closed 7 years ago

brettz9 commented 7 years ago

For the one last item not under the user's control, I believe we ought to add magic for types to short-circuit our internal use of isPlainObject, e.g., so that, when special properties have been added via the likes of Object.defineProperty, a "plain" object can be treated as a special one.

This short-circuiting might be as simple as defining a boolean like isPlainObject: true on the type (this would also fit into https://github.com/dfahlander/typeson/issues/1 ) so its tester (which I think would be a bit better renamed to detector, btw, if that's ok) could ensure a match avoided the normal object cloning routine.

I think such a boolean would be superior to forcing the user to have to pass config to achieve this effect as a boolean would avoid breaking modularity.

brettz9 commented 7 years ago

Sorry again, meant for this to be on Typeson repo.