1.0.3 • Published 7 years ago

defined-object v1.0.3

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

Defined Object

Usage

const definedObject = require('defined-object')

const CONSTANTS = definedObject({
  IMPORTANT_IMMUTABLE_CONST: 'bar',
  API_KEY: 'sh',
  POOL_AMT: 5,
});

CONSTANTS.IMPORTANT_IMMUTABLE_CONST
// 'bar'

CONSTANTS.what_the_f_are_you_doing
// Error: Undefined property what_the_4_are_you_doing on { IMPORTANT_IMMUTABLE_CONST: 'bar', API_KEY: 'sh', POOL_AMT: 5 }

CONSTANTS.IMPORTANT_IMMUTABLE_CONST = "oops"
// Error: Cannot set properties on read only object

Why?

This came out of multiple production breakages related to CONSTANT.Property === Something and no error was being thrown because CONSTANT.Property was undefined and silently failing while CONSTANT.property was the actual value.

Crash early.

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago