2.1.4 • Published 3 years ago
@dizmo/functions-deprecated v2.1.4
@dizmo/functions-deprecated
A decorator to deprecate class methods (and properties): It takes an optional message (or function) and returns the original method, where a [DEPRECATED] Class.method: message text is printed at most once upon invoking the deprecated method (using console.warn).
Usage
Installation
npm install @dizmo/functions-deprecated --saveRequire
import { deprecated } from '@dizmo/functions-deprecated';
import { original } from '@dizmo/functions-deprecated';Example(s)
class MyClass {
@deprecated
method1() { ... }
@deprecated('message')
method2() { ... }
@deprecated((self, key) => 'message')
method3() { ... }
}..where self instanceof MyClass and key === 'method3'.
const instance = new MyClass();
original(instance.method).bind(instance)();..where bind(instance) is required!
class MyClass {
@deprecated
static method1() { ... }
@deprecated('message')
static method2() { ... }
@deprecated((self, key) => 'message')
static method3() { ... }
}..where self === MyClass and key === 'method3'.
original(MyClass.method).bind(MyClass)();..where bind(MyClass) is required!
Development
Clean
npm run cleanBuild
npm run buildwithout linting and cleaning:
npm run -- build --no-lint --no-cleanwith UMD bundling (incl. minimization):
npm run -- build --prepackwith UMD bundling (excl. minimization):
npm run -- build --prepack --no-minifyLint
npm run lintwith auto-fixing:
npm run -- lint --fixTest
npm run testwithout linting, cleaning and (re-)building:
npm run -- test --no-lint --no-clean --no-buildCover
npm run coverwithout linting, cleaning and (re-)building:
npm run -- cover --no-lint --no-clean --no-buildDocumentation
npm run docsPublication
npm publishinitially (if public):
npm publish --access=publicCopyright
© 2021 dizmo AG, Switzerland