Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

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.

Install

npm i explodey

DownloadsWeekly Downloads

2

Version

1.0.1

License

ISC

Unpacked Size

4.99 kB

Total Files

6

Last publish

Collaborators

  • avatar