Skip to content

Commit

Permalink
docs: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Jan 28, 2024
1 parent 9f2efa2 commit 530fc42
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# decorator-utils
> Universal decorator factories made from scratch
[![Maintainability](https://api.codeclimate.com/v1/badges/4c341fd87383813f8e18/maintainability)](https://codeclimate.com/github/qiwi/decorator-utils/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/4c341fd87383813f8e18/test_coverage)](https://codeclimate.com/github/qiwi/decorator-utils/test_coverage)

Universal decorator factories made from scratch

## Install
```bash
yarn add @qiwi/decorator-utils
Expand All @@ -18,7 +17,7 @@ Holy War thread: [wycats/javascript-decorators/issues/23](https://github.com/wyc

## Usage
#### Method
```typescript
```ts
import {constructDecorator} from '@qiwi/decorator-utils'

const decorator = constructDecorator((targetType, target, param) => {
Expand All @@ -36,7 +35,7 @@ class Foo {
```

#### Class
```typescript
```ts
const decorator = constructDecorator((targetType, target) => {
if (targetType === CLASS) {
return class Bar extends target {
Expand All @@ -58,7 +57,7 @@ class Foo {
```

#### Field & Param
```typescript
```ts
import {createDecorator, FIELD, PARAM} from '@qiwi/decorator-utils'

const meta: any = {}
Expand Down Expand Up @@ -105,7 +104,7 @@ class Foo {

You may also apply the decorator to the class, but decorate its methods:

```typescript
```ts
const decorator = constructDecorator((targetType, target) => {
if (targetType === METHOD) {
return () => {
Expand All @@ -125,7 +124,7 @@ class Foo {
`constructDecorator` factory provides the handler access to the decorator context.
This data describes the specifics of the decorated target, decorator arguments and so on.

```typescript
```ts
type IDecoratorHandlerContext = {
args: IDecoratorArgs
kind: ITargetType | null // targetType alias
Expand Down

0 comments on commit 530fc42

Please sign in to comment.