# decreator

> makes creating decorator wrappers easier

Latest version **0.0.0** (published 2016-11-10) · MIT license · 0 weekly downloads

## Install

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

## 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.0.0 |
| Published | 2016-11-10 |
| First published | 2016-11-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Chad Scira |
| Maintainers | icodeforlove |

## Links

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

## Recent versions

- 0.0.0 (latest) — 2016-11-10

## README

# decreator [![Build Status](https://travis-ci.org/icodeforlove/decreator.png?branch=master)](https://travis-ci.org/icodeforlove/decreator)

### why?

creating flexible decorators are complicated if you want them to act as wrappers, and work cross class/methodtype. **decreator** makes this very simple to do.

## install

```
npm install --save decreator
```

## usage

you can define a universal decorator like this

```javascript
import decreator from 'decreator';

const readonly = decreator((target, key, descriptor, options) => {
    if (options.verbose) {
        console.log(`@readonly ${key}`);
    }

    Object.defineProperty(target, key, {
        value: target[key],
        writable: false
    });

    return target;
});

class Example {
    @readonly
    method () {
    }
}

// or 
@readonly({verbose: true})
class Example {
    method () {
    }
}


```

## decorators with args

the decreator implimentation requires args to be in object form so

`@readonly({verbose: true})` vs `@readonly(true)`

## shortcomings

ignores class properties, this was done because at the moment the spec is up in the air, and currently doesnt support decorators in all scenarios.

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