Socket
Socket
Sign inDemoInstall

deprecated-decorator

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    deprecated-decorator

A simple decorator for deprecated methods and properties.


Version published
Weekly downloads
567K
increased by5.2%
Maintainers
1
Install size
15.9 kB
Created
Weekly downloads
 

Readme

Source

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:

  • TypeScript with experimentalDecorators option enabled.
  • Babel with transform-decorators-legacy for version 6.x.

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.

Keywords

FAQs

Last updated on 12 Apr 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc