1.0.3 • Published 2 years ago

exceptional-objects v1.0.3

Weekly downloads
1
License
GPL-3.0
Repository
github
Last release
2 years ago

exceptional objects

create strict objects that will throw an exception if you try to get a property from them that they don't have.

uses Proxy.

here's some typed up:

const exceptional = require('exceptional-objects')
const dog = exceptional({bark: 'woof', color: 'tan'})
dog.bark
//-> 'woof'
dog.color
//-> 'tan'
dog.name
//-> throws "Error: Object does not contain name"

you can still set things like normal:

const lol = exceptional({})
console.log(lol.dog) //-> throws "Error: Object does not contain dog"
lol.dog = 'henry'
console.log(lol.dog) //-> henry
1.0.3

2 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago