# @simulacron/decorators

> Some useful decorators.

Latest version **1.0.2** (published 2023-08-01) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install @simulacron/decorators
pnpm add @simulacron/decorators
yarn add @simulacron/decorators
bun add @simulacron/decorators
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-08-01 |
| First published | 2023-08-01 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andy Chentsov |
| Maintainers | andyduke |
| Keywords | decorator, annotation, bind, autobind, debounce, throttle |

## Links

- npm: https://www.npmjs.com/package/@simulacron/decorators
- Repository: https://github.com/andyduke/lit-widget
- Homepage: https://github.com/andyduke/lit-widget/packages/decorators#readme
- Issues: https://github.com/andyduke/lit-widget/issues
- npm.io page: https://npm.io/package/@simulacron/decorators

## Dependencies (1)

- [@simulacron/tools](https://npm.io/package/@simulacron/tools.md) ^1.0.1

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2023-08-01
- 1.0.1 — 2023-08-01
- 1.0.0 — 2023-08-01

## README

# Decorators

A set of handy JavaScript decorators.


## autobind

Binds a class context to a method.

Allows you to use class methods as an event handler, without the additional `bind`:
```js
connectedCallback() {
  // ...
  this.addEventListener('click', this.toggle);
}

disconnectedCallback() {
  this.removeEventListener('click', this.toggle);
  // ...
}

@autobind()
toggle(event) {

}
```

Such methods can be used in `removeEventListener` since they are pointers to the same instance used in `addEventListener`.


## debounce

Debounce the execution of the method.

You can specify the value in milliseconds as a number or in string format with the suffix `'<delay>ms'`, supported suffixes: ms - milliseconds, s - seconds, m - minutes.

This can be handy for events such as key presses or "input" in input fields.

```js
@debounce('300ms')
inputChanged(event) {
  // ...
}
```


## throttle

Throttle the execution of the method.

You can specify the value in milliseconds as a number or in string format with the suffix `'<delay>ms'`, supported suffixes: ms - milliseconds, s - seconds, m - minutes.

This can be handy for "resize" or "scroll" events.

```js
@throttle('500ms')
resizeChanged(event) {
  // ...
}
```

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