🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

qbject

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qbject

Optional object chaining & creation with ES6 Proxys

2.0.9
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

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'

FAQs

Package last updated on 05 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts