# object-getset

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

Latest version **0.1.4** (published 2014-03-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install object-getset
pnpm add object-getset
yarn add object-getset
bun add object-getset
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2014-03-14 |
| First published | 2013-10-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Joshua Anderson |
| Maintainers | kr1zmo |

## Links

- npm: https://www.npmjs.com/package/object-getset
- Repository: http://github.com/kr1zmo/object-getset
- Homepage: https://github.com/kr1zmo/object-getset
- Issues: https://github.com/kr1zmo/object-getset/issues
- npm.io page: https://npm.io/package/object-getset

## Recent versions

- 0.1.4 (latest) — 2014-03-14
- 0.1.3 — 2013-10-31
- 0.1.2 — 2013-10-30
- 0.1.1 — 2013-10-14

## 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*
> ```html
> <script type="text/javascript" src="getset.js"></script>
> ```

**AMD**:
> *If you are using require.js or AMD you can require getset.*
> ```javascript
> 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

---
_Source: https://npm.io/package/object-getset · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
