trespass

1.0.1 • Public • Published

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.

Package Sidebar

Install

npm i trespass

Weekly Downloads

1

Version

1.0.1

License

BSD-3-Clause

Last publish

Collaborators

  • rickwong