# setter-getterify

> generates setters and getters for an object

Latest version **1.1.0** (published 2015-04-17) · Apache 2 license · 0 weekly downloads

## Install

```sh
npm install setter-getterify
pnpm add setter-getterify
yarn add setter-getterify
bun add setter-getterify
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2015-04-17 |
| First published | 2015-04-16 |
| Weekly downloads | 0 |
| License | Apache 2 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | sole |
| Maintainers | sole |
| Keywords | setters, getters |

## Links

- npm: https://www.npmjs.com/package/setter-getterify
- Repository: https://github.com/sole/setter-getterify
- Issues: https://github.com/sole/setter-getterify/issues
- npm.io page: https://npm.io/package/setter-getterify

## Recent versions

- 1.1.0 (latest) — 2015-04-17
- 1.0.0 — 2015-04-16

## README

# setter-getterify

> generates setters and getters for an object

## Syntax

```javascript
setterGetterify(object, properties, callbacks);
```

## Example

```javascript
var setterGetterify = require('setter-getterify');

var thing = { some: 'properties' };
var coords = { x: 0, y: 0 };

setterGetterify(thing, coords, {
	afterSetting: function(property, value) {
		console.log(property, 'was set to', value);
	}
});

console.log(thing);
console.log(thing.x);

thing.x = 123;

console.log(thing);
console.log(coords);
```

```bash
{ some: 'properties', x: [Getter/Setter], y: [Getter/Setter] }
0
x was set to 123
{ some: 'properties', x: [Getter/Setter], y: [Getter/Setter] }
{ x: 123, y: 0 }
```

The values are not stored on the `object` but in the `properties` object. This can be used to keep them private and make sure they are only accessed with said setters/getters.

This is useful if you only care about that data when storing/retrieving the object for example.

The `callbacks` parameter is entirely optional. Currently only `afterGetting` is implemented.

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