Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vilicvane/deprecated-decorator
A simple decorator for deprecated methods and properties.
https://github.com/vilicvane/deprecated-decorator
Last synced: 20 days ago
JSON representation
A simple decorator for deprecated methods and properties.
- Host: GitHub
- URL: https://github.com/vilicvane/deprecated-decorator
- Owner: vilicvane
- License: mit
- Created: 2016-01-03T18:04:04.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-01-24T10:51:29.000Z (almost 5 years ago)
- Last Synced: 2024-11-29T20:49:26.457Z (24 days ago)
- Language: TypeScript
- Size: 32.2 KB
- Stars: 32
- Watchers: 2
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![NPM Package](https://badge.fury.io/js/deprecated-decorator.svg)](https://www.npmjs.com/package/deprecated-decorator)
[![Build Status](https://travis-ci.org/vilic/deprecated-decorator.svg)](https://travis-ci.org/vilic/deprecated-decorator)# 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](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy) for version 6.x.## Install
```sh
npm install deprecated-decorator --save
```## API References
```ts
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(fn: T): T;
export declare function deprecated(options: DeprecatedOptions, fn: T): T;
export declare function deprecated(alternative: string, fn: T): T;
export declare function deprecated(alternative: string, version: string, fn: T): T;
export declare function deprecated(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):
```ts
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:
```ts
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:
```ts
import deprecated from 'deprecated-decorator';let foo = deprecated({
alternative: 'bar',
version: '0.1.0'
}, function foo() {
// ...
});
```## License
MIT License.