# @aster-js/decorators

> Aster decorator library part of Aster js library

Latest version **1.1.0** (published 2024-01-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install @aster-js/decorators
pnpm add @aster-js/decorators
yarn add @aster-js/decorators
bun add @aster-js/decorators
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2024-01-14 |
| First published | 2021-01-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 23.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | sebdoucet |
| Maintainers | aster-js |

## Links

- npm: https://www.npmjs.com/package/@aster-js/decorators
- Repository: https://github.com/asterlibraryjs/aster-js-decorators
- Homepage: https://github.com/asterlibraryjs/aster-js-decorators#readme
- Issues: https://github.com/asterlibraryjs/aster-js-decorators/issues
- npm.io page: https://npm.io/package/@aster-js/decorators

## Dependencies (2)

- [tslib](https://npm.io/package/tslib.md) ^2.6.2
- [@aster-js/core](https://npm.io/package/@aster-js/core.md) ^1.3.0

## Recent versions

- 1.1.0 (latest) — 2024-01-14
- 1.0.1 — 2021-10-31
- 1.0.0 — 2021-02-01
- 1.0.0-beta.1 — 2021-01-17

## README

# @aster-js/decorator

## Memoize

The memoize decorator allow create an accessor that will cache the result for further calls

```ts
class Sample {
    private readonly _url: string;
    private readonly _parser: IUrlParser;

    @Memoize get routeData(): Record<string, any> { return this._parser.parse(this._url); }
}
```


## Stored

The @Stored will use localStorage or sessionStorage to store the value of an accessor.

```ts
class Sample {
    @Stored({ dataType: String, storage: sessionStorage, timeout: 30 * 60 * 1000 /* 30 mins*/ })
    token?: string;
}
```

### Options

- `dataType`: Use to validate the input value and by the converter.
- `storage`: Allow to switch between local or session storage. Custom implementation can also be pprovided.
- `converter`: Convert the value to and from the storage. The converter expect a callback and the call will provide two arguments, the value that need to be converted and the type expected: when the value is converter for the storage, the type expected will be string, when the converter is call in the other way, the `dataType` is provided.
- `timeout`: The timeout is used to deprecate the value in the storage. After the delay, no value will be returned.

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