poison-get

Throw when a user attempts to access specified properties in an object

Usage no npm install needed!

<script type="module">
  import poisonGet from 'https://cdn.skypack.dev/poison-get';
</script>

README

poison-get Build Status

Throw when a user attempts to access specified properties in an object

Install

$ npm install --save poison-get

Usage

var poison = require('poison-get')

var obj = poison({}, 'foo')
obj.foo
//=> throws Error

API

poison(obj, keys, [message]) -> object

obj

Required
Type: object

An object to modify with poison getters.

keys

Required
Type: string / array[string]

The key (or keys) where poison getters will be assigned.

message

Type: string

An error message to use when throwing

License

MIT © Ben Drucker