Skip to content

Commit

Permalink
docs: add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Velmisov committed Jul 19, 2020
1 parent 800f38e commit b0ce914
Showing 1 changed file with 68 additions and 1 deletion.
69 changes: 68 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,71 @@

## Description

Extend class with its metadata
Extend/override metadata of parent classes.

## Installation

```bash
npm install extend-metadata
```

## API

`@Extend()` - class decorator. Use it to extend all parent classes metadata.

`@Override()` - property/method decorator. Use it to extend particular metadata.

## Usage

### Extend

```typescript
@AddClassMetadata()
class Animal {
@AddPropertyMetadata()
property: Type;

@AddMethodMetadata()
method(): Type {}
}

@Extend()
class Cat extends Animal { // has the same metadata
property: Type; // also has the same metadata

@AddAnotherMethodMetadata()
method(): Type { // has another metadata
return super.method();
}
}
```

### Override

```typescript
@AddClassMetadata()
class Animal {
@AddPropertyMetadata()
property: Type;

@AddMethodMetadata()
method(): Type {}
}

class Cat extends Animal { // doesn't have metadata from Animal
@Override()
property: Type; // has the same metadata

method(): Type { // no metadata
return super.method();
}
}
```

## Requirements

`reflect-metadata: ^0.1.13`

## License

extend-metadata is [MIT licensed](LICENSE).

0 comments on commit b0ce914

Please sign in to comment.