UNPKG

1.23 kBTypeScriptView Raw
1/** Returns whether bundler-injected variable `NODE_ENV` equals `env`. */
2export declare function isNodeEnv(env: string): boolean;
3/**
4 * Returns the difference in length between two arrays. A `null` argument is
5 * considered an empty list. The return value will be positive if `a` is longer
6 * than `b`, negative if the opposite is true, and zero if their lengths are
7 * equal.
8 */
9export declare function arrayLengthCompare(a?: any[], b?: any[]): number;
10/**
11 * Returns true if the two numbers are within the given tolerance of each other.
12 * This is useful to correct for floating point precision issues, less useful
13 * for integers.
14 */
15export declare function approxEqual(a: number, b: number, tolerance?: number): boolean;
16/**
17 * Clamps the given number between min and max values. Returns value if within
18 * range, or closest bound.
19 */
20export declare function clamp(val: number, min: number, max: number): number;
21/** Returns the number of decimal places in the given number. */
22export declare function countDecimalPlaces(num: number): number;
23/** Generate a unique ID within a given namespace, using a simple counter-based implementation to avoid collisions. */
24export declare function uniqueId(namespace: string): string;