UNPKG

@ayonli/jsext

Version:

A JavaScript extension package for building strong and modern applications.

54 lines (53 loc) 1.24 kB
/** * Functions for mathematical calculations. * @module */ /** * Returns the sum value of the given values. * * @example * ```ts * import { sum } from "@ayonli/jsext/math"; * * console.log(sum(1, 2, 3)); // 6 * console.log(sum(1, 2, 3, 4, 5)); // 15 * ``` */ export declare function sum(...values: number[]): number; /** * Returns the average value of the given values. * * @example * ```ts * import { avg } from "@ayonli/jsext/math"; * * console.log(avg(1, 2, 3)); // 2 * console.log(avg(1, 2, 3, 4, 5)); // 3 * ``` */ export declare function avg(...values: number[]): number; /** * Returns a the product value multiplied by the given values. * * @example * ```ts * import { product } from "@ayonli/jsext/math"; * * console.log(product(1, 2, 3)); // 6 * console.log(product(1, 2, 3, 4, 5)); // 120 * ``` */ export declare function product(...values: number[]): number; /** * Returns the rounded value of the given number. * * @example * ```ts * import { round } from "@ayonli/jsext/math"; * * console.log(round(1.2345)); // 1 * console.log(round(1.2345, 2)); // 1.23 * console.log(round(1.2345, 3)); // 1.235 * ``` */ export declare function round(value: number, precision?: number): number;