npm.io
1.0.2 • Published 2 years ago

@types/parse-decimal-number

Licence
MIT
Version
1.0.2
Deps
0
Size
6 kB
Vulns
0
Weekly
0
Stars
51.4K

Installation

npm install --save @types/parse-decimal-number

Summary

This package contains type definitions for parse-decimal-number (https://github.com/AndreasPizsa/parse-decimal-number).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/parse-decimal-number.

index.d.ts

declare namespace parseDecimalNumber {
    type ArrayOptions = [thousands: string, decimal: string];

    interface HashOptions {
        /**
         * Decimal point character.
         * Default: ".".
         */
        decimal: string;
        /**
         * Thousands separator character.
         * Default: ",".
         */
        thousands: string;
    }

    type Options = ArrayOptions | HashOptions | string;

    /**
     * Has the same effect as `parseDecimalNumber.setOptions({ thousands: ",", decimal: "." })`.
     */
    function factoryReset(): void;
    /**
     * Set the default thousands and decimal characters that are used when no options are passed to
     * {@link parseDecimalNumber}.
     */
    function setOptions(hash: HashOptions): void;
    /**
     * Returns a function that will take a string as an argument and return a float or `NaN`,
     * just like {@link parseDecimalNumber}.
     */
    function withOptions(options: Options, enforceGroupSize?: boolean): (string: string) => number;
}

declare function parseDecimalNumber(
    /**
     * A string that is supposed to contain a number.
     */
    string: string,
    /**
     * A string, array or hash with thousands and decimal separators.
     */
    options?: parseDecimalNumber.Options,
    /**
     * A boolean indicating whether to support that individual groups between the thousands
     * character are exactly 3 digits.
     */
    enforceGroupSize?: boolean,
): number;

export = parseDecimalNumber;

Additional Details

  • Last updated: Tue, 07 Nov 2023 0939 GMT
  • Dependencies: none

Credits

These definitions were written by Ciarán Ingle.