1.0.2 • Published 7 years ago

ensure-key v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

Ensure-Key

Lets you access members of an object safely (will be added if missing and initialized to a value you provide).

How to use:

import './Ensure'; 

const registry = {}; 

registry.ensure('abc', {}).ensure('items', []).push(123); 

console.log(registry);  // --> { abc: { items: [ 123 ] } }

The ensure method is added to the Object prototype and is thus available on every object. It is hidden from enumeration (to not cause interferences with environments).