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 🙏

© 2025 – Pkg Stats / Ryan Hefner

object-getset

v0.1.4

Published

A simple module for safely - accessing / modifying - chained properties on objects without the unnecessary hassle.

Readme

#Object Get/Set A simple module for safely - accessing / modifying - chained properties on objects without the unnecessary hassle.

Current Version: 0.1.4 Tested with Node: 0.10.20 >= Tested with REQUIREJS: 2.1.8 >=

Features:

  • Lightweight and Efficient
  • AMD support
  • NPM published
  • Abstracted into module to prevent global issues (unless not using module system)
  • Speed optimized
  • Quick and efficient property accesses.
  • We need battle-testers.

#Install/Require:

In-line Script:

Add getset.js to html page

<script type="text/javascript" src="getset.js"></script>

AMD:

If you are using require.js or AMD you can require getset.

require(['getset'], function(GetSet) {
  console.log(GetSet);
});

**Node**:
> *Add getset.js to project folder and require*
> ```javascript
> var GetSet = require('./getset');
> console.log(GetSet);
> ```

**NPM (Node) - [Link](http://npmjs.org/package/object-getset)**:

> *Install the module*
> `[sudo] npm install -g object-getset` or `npm install object-getset`
>
> ```javascript
> var GetSet = require('object-getset');
> console.log(GetSet);
> ```

#Example:
View the index.html in the example/ folder for use and examples (both global and requirejs [AMD]).

#Methods:
When not using a module system (node, requirejs, amd), getset will expose `getProperty` and `setProperty` methods to the global name-space (mainly browser environment); otherwise, it will provide the methods on an exported object.

#Documentation:

GetSet provides two methods for handling *objects*.

### getProperty([object], [string]);
> Safely accesses a chained property on an object; useful for complex if statements without throwing an error due to an access attempt on a property of an *undefined* object
>
> **Arguments:**
> * 1. object: The object to search.
> * 2. string: The string containing a chained value of the value desired. e.g. 'kitchen.sink'.

> **Returns:**
> * (Any object type): Returns the value of the specified chained value; otherwise, will return undefined. e.g. object, string, array, boolean, null, undefined
>

> **Example:**
> ```javascript
> getProperty({classes: {semesters: 3}}, 'classes.semesters');
> ```

### setProperty([object], [string], [value]);
> Safety - modifies/creates - a chained property on an object; useful for adding complex chained values without creating prior objects. Will completely avoid throwing an error when setting a property of an undefined object. *Quick and easy*.
>
> **Arguments:**
> * 1. object: The object to set a value upon.
> * 2. string: The string containing a chained value e.g. 'kitchen.sink'.
> * 3. value (any object type): The desired value.
>
> **Returns:**
> * (Object): Returns the object supplied, always; will be the modified version.

> **Example:**
> ```javascript
> setProperty({classes: {semesters: 3}}, 'classes.semesters', 4);
> ```


#Log:

V0.1.3 - (10/31/13):
  * Re-factor of `setProperty` to only create object property if it doesn't exist. Otherwise, it will recognize the object, preserve it, and simply add the supplied data

v0.1.2 - (10/30/13):
  * Re-factor of `setProperty` method to support defining undefined properties in objects
  * Consistency with `getProperty`: better support of false values (will now return undefined if  property accessed is not present or property searched is not an object)
  * Stability and more simple `setProperty` method

v0.1.1 - (10/14/13):
  * Updated documentation - (spelling)
  * Cleaned comments
  * Changed program variables
  * Simple re-factor - stability enhancement

v0.1.0-B1 - (10/13/13):
  * Initial Commit