Natural Performance Manager

    @dizmo/functions-before
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.15 • Public • Published

    NPM version Build Status Coverage Status

    @dizmo/functions-before

    Returns a function decorating an original function with a callback, which will be invoked before the execution of the original function. The callback can block the invocation of the original function by returning false.

    Usage

    Install

    npm install @dizmo/functions-before --save

    Require

    const { before } = require("@dizmo/functions-before");

    Examples

    import { before } from "@dizmo/functions-before";
    const f1 = (value: number): number => {
        return value;
    };
    const f2 = before(f1, (
        fn: Function, value: number
    ): boolean|undefined => {
        const expect = value === 0 || value === 1;
    });
    const expect0 = f2(0) === 0;
    const expect1 = f2(1) === 1;
    class Class {
        @before.decorator((
            fn: Function, value: number
        ): boolean|undefined => {
            return false; // blocks method invocation!
        })
        public method(value: number): number {
            return value;
        }
    }
    const expect0 = new Class().method(0) === undefined;
    const expect1 = new Class().method(1) === undefined;

    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

    Install

    npm i @dizmo/functions-before

    DownloadsWeekly Downloads

    6

    Version

    1.0.15

    License

    ISC

    Unpacked Size

    26.4 kB

    Total Files

    19

    Last publish

    Collaborators

    • dizmo-user
    • hsk81