# defined-object

> Objects which enforce reading only defined properties

Latest version **1.0.3** (published 2017-08-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install defined-object
pnpm add defined-object
yarn add defined-object
bun add defined-object
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2017-08-01 |
| First published | 2017-08-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Julian Knodt |
| Maintainers | tomzer0 |
| Keywords | Object, freeze, strict |

## Links

- npm: https://www.npmjs.com/package/defined-object
- npm.io page: https://npm.io/package/defined-object

## Recent versions

- 1.0.3 (latest) — 2017-08-01
- 1.0.2 — 2017-08-01
- 1.0.1 — 2017-08-01
- 1.0.0 — 2017-08-01

## README

# Defined Object

## Usage
```js
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.

---
_Source: https://npm.io/package/defined-object · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
