npm.io
1.1.3 • Published 5 years ago

extend-metadata

Licence
MIT
Version
1.1.3
Deps
0
Size
12 kB
Vulns
0
Weekly
0
Stars
1

extend-metadata

Travis Coverage Status node npm

GitHub top language GitHub code size in bytes David David

license GitHub last commit semantic-release

Description

Extend/override metadata of parent classes.

Installation

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
@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
@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.