Giter Site home page Giter Site logo

deprecated-decorator's Introduction

NPM Package Build Status

Deprecated Decorator

A simple decorator for deprecated properties, methods and classes. It can also wrap normal functions via the old-fashioned way.

Transpilers supported:

Install

npm install deprecated-decorator --save

API References

export declare type DeprecatedDecorator = ClassDecorator & PropertyDecorator;

export interface DeprecatedOptions {
    alternative?: string;
    version?: string;
    url?: string;
}

export declare function deprecated(options?: DeprecatedOptions): DeprecatedDecorator;
export declare function deprecated(alternative?: string, version?: string, url?: string): DeprecatedDecorator;

export declare function deprecated<T extends Function>(fn: T): T;
export declare function deprecated<T extends Function>(options: DeprecatedOptions, fn: T): T;
export declare function deprecated<T extends Function>(alternative: string, fn: T): T;
export declare function deprecated<T extends Function>(alternative: string, version: string, fn: T): T;
export declare function deprecated<T extends Function>(alternative: string, version: string, url: string, fn: T): T;

export default deprecated;

Usage

Decorating a class will enable warning on constructor and static methods (including static getters and setters):

import deprecated from 'deprecated-decorator';

// alternative, since version, url
@deprecated('Bar', '0.1.0', 'http://vane.life/')
class Foo {
    static method() { }
}

Or you can decorate methods respectively:

import deprecated from 'deprecated-decorator';

class Foo {
    @deprecated('otherMethod')
    method() { }
    
    @deprecated({
        alternative: 'otherProperty',
        version: '0.1.2',
        url: 'http://vane.life/'
    })
    get property() { }
}

For functions:

import deprecated from 'deprecated-decorator';

let foo = deprecated({
    alternative: 'bar',
    version: '0.1.0'
}, function foo() {
    // ...
});

License

MIT License.

deprecated-decorator's People

Contributors

vilicvane avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.