explodey

1.0.1 • Public • Published

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.

Package Sidebar

Install

npm i explodey

Weekly Downloads

2

Version

1.0.1

License

ISC

Unpacked Size

4.99 kB

Total Files

6

Last publish

Collaborators

  • wiski