@dizmo/functions-after
Returns a function decorating an original function with a callback, which will be invoked after the execution of the original function. The return value of the original function will be handed over to the after callback as an argument, while the return value of the callback will become the overall result.
Usage
Install
npm install @dizmo/functions-after --save
Require
const { after } = require("@dizmo/functions-after");
Examples
import { after } from "@dizmo/functions-after";
const f1 = (): number => {
return 1;
};
const f2 = after(f1, (n: number): number => {
return n + 1;
});
const expect = 2 === f2();
class Class {
@after.decorator((n: number): number => {
return n + 1;
})
public method(): number {
return 1;
}
}
const expect = 2 === new Class().method();
Development
Clean
npm run clean
Build
npm run build
without linting and cleaning:
npm run -- build --no-lint --no-clean
with UMD bundling (incl. minimization):
npm run -- build --prepack
with UMD bundling (excl. minimization):
npm run -- build --prepack --no-minify
Lint
npm run lint
with auto-fixing:
npm run -- lint --fix
Test
npm run test
without linting, cleaning and (re-)building:
npm run -- test --no-lint --no-clean --no-build
Cover
npm run cover
without linting, cleaning and (re-)building:
npm run -- cover --no-lint --no-clean --no-build
Documentation
npm run docs
Publish
npm publish
initially (if public):
npm publish --access=public
Copyright
© 2020 dizmo AG, Switzerland