constant
Wraps non-function variables in a simple return function.
Basic example
Section titled “Basic example”Wraps a plain value in a function that ignores its arguments and returns the value. Config such as fill: "#f03e3e" or width: 10 is normalized this way, so shapes can call every setting as an accessor without checking whether it was given as a value or a function.
import {constant} from "@d3plus/core";
constant(42)();
constant("#f03e3e")({id: "alpha"});
[1, 2, 3].map(constant("same"));
Parameters
import {constant} from "@d3plus/core";
valuerequiredTThe value to wrap in a return function.