1.0.1 • Published 6 years ago

explodey v1.0.1

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

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.