• Creates a string template replacer function.

    Parameters

    Returns StringReplacer

    string replacer function.

    Example: _Adjust options to change not found values_

    import {customReplacer} from "apprt-core/string-replace";

    const replace = customReplacer({
    valueNotFound: ""
    });

    let msg = replace("${name} says ${msg}",{msg: "hello" });
    msg === " says hello"; // true

    Example: _Custom value lookup function_

    import {customReplacer} from "apprt-core/string-replace";

    const replace = customReplacer({
    // use custom key value lookup function
    valueLookup: (key, values) => values[key]
    });

    let msg = replace("Says ${msg}",{msg: "hello" });
    msg === "Says hello"; // true

Generated using TypeDoc