JSPM

trespass

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q28386F
  • License BSD-3-Clause

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

Package Exports

  • trespass

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (trespass) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.