2.0.9 • Published 6 years ago

qbject v2.0.9

Weekly downloads
61
License
-
Repository
github
Last release
6 years ago

Optional object chaining & creation with ES6 Proxys

Arbitrary property access with a default value. When setting a property, missing objects in the chain are created automatically.

Exports a global 'Qbject' when dumped in your page as a script tag.

You could use this or this or this instead if you just need optional chaining.

Install

$ yarn add qbject

Params

object to wrap ({})
default value (undefined)
unwrap key ('_')

Examples

import Qbject from 'qbject';

const obj1 = Qbject();

console.log(obj1.bar.bar.baz._); // 'undefined'

obj1.arbitrary.deep.mutation = true;

console.log(obj1._); // {"arbitrary":{"deep":{"mutation":true}}}

obj1.foo = 'data';

console.log(obj1.foo._); // 'data'

const obj2 = Qbject({foo: 'test'}, 'something');

console.log(obj2._); // { foo: 'test' }
console.log(obj2.foo._); // 'test'
console.log(obj2.bar._); // 'something'
console.log(obj2.bar.bar._); // 'something'
2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago