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.
npm install @dizmo/functions-after --saveconst { after } = require("@dizmo/functions-after");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();npm run cleannpm run buildnpm run -- build --no-lint --no-cleannpm run -- build --prepacknpm run -- build --prepack --no-minifynpm run lintnpm run -- lint --fixnpm run testnpm run -- test --no-lint --no-clean --no-buildnpm run covernpm run -- cover --no-lint --no-clean --no-buildnpm run docsnpm publishnpm publish --access=public© 2020 dizmo AG, Switzerland