# stdprop

> Define object properties without boilerplate

Latest version **1.0.2** (published 2020-05-05) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install stdprop
pnpm add stdprop
yarn add stdprop
bun add stdprop
```

## 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.0.2 |
| Published | 2020-05-05 |
| First published | 2020-01-14 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Brecht Savelkoul |
| Maintainers | savelbr |
| Keywords | object, defineProperty, property, define, enumerable, writable, configurable, getter, setter, get, set |

## Links

- npm: https://www.npmjs.com/package/stdprop
- Repository: https://github.com/brechtcs/stdprop
- Homepage: https://github.com/brechtcs/stdprop#readme
- Issues: https://github.com/brechtcs/stdprop/issues
- npm.io page: https://npm.io/package/stdprop

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-05-05
- 1.0.1 — 2020-01-15
- 1.0.0 — 2020-01-14

## README

# stdprop

Define object properties without boilerplate

## Usage

With this modules, you can define object properties using the following shorthand (original longhand included for reference):

```js
var prop = require('stdprop')
var obj = {}

// non-enumerable and non-writable
// with stdprop:
prop(obj, 'one', 'stuff')

// previously:
Object.defineProperty(obj, 'stuff', {
  value: 'stuff'
})

// enumerable and non-writable
// with stdprop:
prop(obj, 'one', 'stuff', 'e')

// previously:
Object.defineProperty(obj, 'stuff', {
  value: 'stuff',
  enumerable: true
})

// enumerable and writable
// with stdprop:
prop(obj, 'one', 'stuff', 'ew')

// previously:
Object.defineProperty(obj, 'stuff', {
  value: 'stuff',
  enumerable: true,
  writable: true
})
```

### getters & setters

Also included are two shorthand methods to create getters and setters on any given object.

```js
var { getter, setter } = require('stdprop')

var interface = {}
var storage = {}
setter(interface, 'shout', function (str) { storage.shout = str.toUpperCase() })
getter(interface, 'shout', function () { return storage.shout + '!' })

interface.shout = 'hello'
console.log(interface.shout) // => 'HELLO!'
console.log(storage.shout) // => 'HELLO'
```

## Acknowledgement

The idea of using shorthand flags to create property descriptors was taken from the existing module [prr](https://npmjs.org/package/prr).

## License

Apache-2.0

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