explodey
v1.0.1
Published
Utility for disallowing/preventing accessing undefined properties on Javscript objects.
Downloads
4
Maintainers
Readme
Explodey
A utility that disallows accessing undefined properties on objects.
const foo = explodey({
a: true,
b: true,
c: true
});
foo.a // => true
foo.z // => throws Error!
const otherFoo = { ...foo };
otherFoo.baz // => undefined
JSON.stringify(foo) // => '{ "a": "true, "b": true, "c": true}'
Why?
Because sometimes its nice to not have to worry about undefined references on things like:
- Constants
- Business critical values
- Stuff like that
What not just use the classical "getter" - like: someObject.get("propertyThatGetsCheckedByHooks")
?
Because I feel that style is better for a situation where the hooks underneath the .get()
are cover business-y logic situations and I want something else... something less.