https://github.com/media-service-dev/deprecation
A function to trigger deprecations.
https://github.com/media-service-dev/deprecation
deprecation javascript
Last synced: 4 months ago
JSON representation
A function to trigger deprecations.
- Host: GitHub
- URL: https://github.com/media-service-dev/deprecation
- Owner: media-service-dev
- Created: 2021-02-04T14:06:54.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-05T12:43:41.000Z (over 4 years ago)
- Last Synced: 2025-03-16T04:42:38.100Z (7 months ago)
- Topics: deprecation, javascript
- Language: TypeScript
- Homepage: https://media-service.com
- Size: 37.1 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Deprecation
A function to trigger deprecations.
## Install
Just run `yarn install @mscs/deprecation`
## Usage
There a several usages:
Trigger with custom message:
```typescript
import { deprecate } from "@mscs/deprecation";function deprecatedMethod(){
deprecate("deprecatedMethod is deprecated. Use something else instead.");
}
```Trigger with the conventional message:
```typescript
import { deprecate } from "@mscs/deprecation";function deprecatedMethod(){
deprecate(3, 4, 6);
}
```You can change behaviour by set the `triggerHandler` method.
```typescript
import { deprecate, defaultDeprecationTriggerHandler } from "@mscs/deprecation";deprecate.triggerHandler = (message: string, error: Error) => {
// Perform the default behaviour.
defaultDeprecationTriggerHandler(message, error)
// Send deprecation to an endpoint
fetch("https://my-server.tld/api/deprecation", {
method: 'POST',
body: JSON.stringify({ message, error }),
})
.catch(console.error);
}function deprecatedMethod(){
deprecate(3, 4, 6);
}
```