1.0.1 • Published 7 years ago

trespass v1.0.1

Weekly downloads
5
License
BSD-3-Clause
Repository
github
Last release
7 years ago

trespass

Access and chain object properties and methods in a safe manner.

Installation

npm install --save trespass

Usage

import t from 'trespass';

t(null).foo.$; // access undefined properties 
t(undefined).bar().$; // call undefined methods
t(undefined).bar().baz.$; // call undefined methods, and then access undefined properties

const t2 = t.createWrapper('$val'); // trespass with custom terminator
t2(foo).bar.$val; 

Requirements

Node 6.4+. Native Browser support for ES6 Proxies.

Why

Because the official Optional Chaining ?. proposal is still in stage-1 currently, see https://github.com/tc39/proposal-optional-chaining.

Other packages

Community

Let's start one together! After you ★ this project, follow me @rygu on Twitter.

License

BSD 3-Clause license. Copyright © 2017, Rick Wong. All rights reserved.