UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

26 lines (24 loc) 577 B
import { dfdlT } from "@monstermann/dfdl"; //#region src/number/toFixed.ts /** * `toFixed(target, length)` * * Returns a string representation of `target` formatted with exactly `length` digits after the decimal point. * * ```ts * toFixed(3.14159, 2); // "3.14" * toFixed(42, 3); // "42.000" * toFixed(1.005, 2); // "1.01" * ``` * * ```ts * pipe(3.14159, toFixed(2)); // "3.14" * pipe(42, toFixed(3)); // "42.000" * pipe(1.005, toFixed(2)); // "1.01" * ``` */ const toFixed = dfdlT((target, length) => { return target.toFixed(length); }, 2); //#endregion export { toFixed };