npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

safe-proxy

v0.1.0

Published

A utility to allow for safe accessing of nested properties

Readme

safe-proxy

safe-proxy is a Javascript utility to allow for safe accessing of nested properties by soaking up nulls, inspired by Coffeescript's existential operator. It is the spiritual successor to safe-access. My friend Palash had the genius idea of improving safe-access’s syntax for calling functions by using ES6 Proxies. Note that since the ES6 Proxy spec is still in flux (no browsers have implemented the latest spec as of January 2015), this is not meant to be used in production. However, it’s really freakin’ cool, so try it out.

Install

npm install safe-proxy

Usage

Usage of ES6 Proxies is hidden behind a flag in io.js, so in order to use them, you will need to run your application with the --harmony-proxies flag.

Use safe-proxy like this:

var safe = require('safe-proxy');
safe(obj).that.is.very.nested.__value;
// the same as `obj.that.is.very.nested` EXCEPT
// returns undefined if any property in the chain is undefined

You can access arrays and call functions as you normally would. Just remember to access __value at the end.

safe(obj).nested.property.and.array[0].func('some', 'args').__value;

What's going on?

You can think of calling safe(obj) as wrapping obj in an object which will not throw an error no matter what properties you access or functions you call on it (even if obj is undefined, for instance). In order to unwrap the value, you’ll need to access the special property __value.

Development

Install io.js, clone this repo, and then from directory root run npm install. Start running tests with npm test. Tests will re-run when files change.

License

safe-proxy is freely distributable under the terms of the MIT license.