Skip to main content Link Search Menu Expand Document (external link)

NumberBase10Format.ts overview

This module implements a MNumberBase10Format which describes the possible options to format/parse a base-10 number or BigDecimal and implements the formatting/parsing algorithms


Exports Grouped by Category


Constructors

make

Constructor

Signature

declare const make: (params: MTypes.Data<Type>) => Type

Source

Destructors

toDescription

Returns a short description of self, e.g. ‘signed integer’

Signature

declare const toDescription: (self: Type) => string

Source

Getters

eNotationChars

Returns the eNotationChars property of self

Signature

declare const eNotationChars: MTypes.OneArgFunction<Type, ReadonlyArray<string>>

Source

fractionalSeparator

Returns the fractionalSeparator property of self

Signature

declare const fractionalSeparator: MTypes.OneArgFunction<Type, string>

Source

integerPartPadding

Returns the integerPartPadding property of self

Signature

declare const integerPartPadding: MTypes.OneArgFunction<
  Type,
  Option.Option<{ readonly length: number; readonly fillChar: string }>
>

Source

maximumFractionalDigits

Returns the maximumFractionalDigits property of self

Signature

declare const maximumFractionalDigits: MTypes.OneArgFunction<Type, number>

Source

minimumFractionalDigits

Returns the minimumFractionalDigits property of self

Signature

declare const minimumFractionalDigits: MTypes.OneArgFunction<Type, number>

Source

roundingOption

Returns the roundingOption property of self

Signature

declare const roundingOption: MTypes.OneArgFunction<Type, RoundingOption>

Source

scientificNotationOption

Returns the scientificNotationOption property of self

Signature

declare const scientificNotationOption: MTypes.OneArgFunction<Type, ScientificNotationOption>

Source

showNullIntegerPart

Returns the showNullIntegerPart property of self

Signature

declare const showNullIntegerPart: MTypes.OneArgFunction<Type, boolean>

Source

signDisplayOption

Returns the signDisplayOption property of self

Signature

declare const signDisplayOption: MTypes.OneArgFunction<Type, SignDisplayOption>

Source

thousandSeparator

Returns the thousandSeparator property of self

Signature

declare const thousandSeparator: MTypes.OneArgFunction<Type, string>

Source

Instances

dutchStyleInteger

Dutch-style integer MNumberBase10Format instance. Used in countries like Dutch-speaking Belgium, the Netherlands, Germany, Italy, Norway, Croatia, Spain…

Signature

declare const dutchStyleInteger: Type

Source

dutchStyleNumber

MNumberBase10Format instance that uses a comma as fractional separator, a dot as thousand separator and shows at most three fractional digits. Used in countries like Dutch-speaking Belgium, the Netherlands, Germany, Italy, Norway, Croatia, Spain…

Signature

declare const dutchStyleNumber: Type

Source

dutchStyleUngroupedNumber

MNumberBase10Format instance that uses a comma as fractional separator, no thousand separator and shows at most three fractional digits. Used in countries like Dutch-speaking Belgium, the Netherlands, Germany, Italy, Norway, Croatia, Spain…

Signature

declare const dutchStyleUngroupedNumber: Type

Source

fourDigitSignedInteger

4-digit signed integer MNumberBase10Format instance with no thousand separator

Signature

declare const fourDigitSignedInteger: Type

Source

fourDigitUnsignedInteger

4-digit unsigned integer MNumberBase10Format instance with no thousand separator

Signature

declare const fourDigitUnsignedInteger: Type

Source

frenchStyleInteger

French-style integer MNumberBase10Format instance. Used in countries like France, French- speaking Canada, French-speaking Belgium, Denmark, Finland, Sweden…

Signature

declare const frenchStyleInteger: Type

Source

frenchStyleNumber

MNumberBase10Format instance that uses a comma as fractional separator, a space as thousand separator and shows at most three fractional digits. Used in countries like France, French- speaking Canada, French-speaking Belgium, Denmark, Finland, Sweden…

Signature

declare const frenchStyleNumber: Type

Source

frenchStyleUngroupedNumber

MNumberBase10Format instance that uses a comma as fractional separator, no thousand separator and shows at most three fractional digits. Used in countries like France, French-speaking Canada, French-speaking Belgium, Denmark, Finland, Sweden…

Signature

declare const frenchStyleUngroupedNumber: Type

Source

integer

Integer MNumberBase10Format instance with no thousand separator

Signature

declare const integer: Type

Source

signedInteger

SignedInteger MNumberBase10Format instance with no thousand separator

Signature

declare const signedInteger: Type

Source

threeDigitSignedInteger

3-digit signed integer MNumberBase10Format instance with no thousand separator

Signature

declare const threeDigitSignedInteger: Type

Source

threeDigitUnsignedInteger

3-digit unsigned integer MNumberBase10Format instance with no thousand separator

Signature

declare const threeDigitUnsignedInteger: Type

Source

twoDigitSignedInteger

2-digit signed integer MNumberBase10Format instance with no thousand separator

Signature

declare const twoDigitSignedInteger: Type

Source

twoDigitUnsignedInteger

2-digit unsigned integer MNumberBase10Format instance with no thousand separator

Signature

declare const twoDigitUnsignedInteger: Type

Source

ukStyleInteger

Uk-style integer MNumberBase10Format instance. Used in countries like the UK, the US, English- speaking Canada, Australia, Thaïland, Bosnia…

Signature

declare const ukStyleInteger: Type

Source

ukStyleNumber

MNumberBase10Format instance that uses a dot as fractional separator, a comma as thousand separator and shows at most three fractional digits. Used in countries like the UK, the US, English-speaking Canada, Australia, Thaïland, Bosnia…

Signature

declare const ukStyleNumber: Type

Source

ukStyleUngroupedNumber

MNumberBase10Format instance that uses a dot as fractional separator, no thousand separator and shows at most three fractional digits. Used in countries like the UK, the US, English- speaking Canada, Australia, Thaïland, Bosnia…

Signature

declare const ukStyleUngroupedNumber: Type

Source

unsignedInteger

Unsigned integer MNumberBase10Format instance with no thousand separator

Signature

declare const unsignedInteger: Type

Source

Models

BigDecimalExtraction (interface)

Type of the value returned by _bigDecimalExtractor

Signature

export interface BigDecimalExtraction {
  readonly value: BigDecimal.BigDecimal
  readonly match: string
  readonly sign: -1 | 1
  readonly input: string
}

Source

Type (class)

Type that represents a MNumberBase10Format

Signature

declare class Type {
  private constructor({
    thousandSeparator,
    fractionalSeparator,
    showNullIntegerPart,
    integerPartPadding,
    minimumFractionalDigits,
    maximumFractionalDigits,
    eNotationChars,
    scientificNotationOption,
    roundingOption,
    signDisplayOption
  }: MTypes.Data<Type>)
}

Source

make (static method)

Static constructor

Signature

declare const make: (params: MTypes.Data<Type>) => Type

Source

[MData.idSymbol] (method)

Returns the id of this

Signature

declare const [MData.idSymbol]: () => string | (() => string)

Source

thousandSeparator (property)

Thousand separator. Use an empty string for no separator. Usually a string made of at most one character different from fractionalSeparator. Will not throw otherwise but unexpected results might occur.

Signature

readonly thousandSeparator: string

Source

fractionalSeparator (property)

Fractional separator. Usually a one-character string different from thousandSeparator. Will not throw otherwise but unexpected results might occur.

Signature

readonly fractionalSeparator: string

Source

showNullIntegerPart (property)

Formatting:

  • If true, numbers with a null integer part are displayed starting with 0. Otherwise, they are displayed starting with . unless maximumFractionalDigits===0, in which case they are displayed starting with 0.

Parsing

  • If true, conversion will fail for numbers starting with . (after an optional sign).
  • If false, conversion will fail for numbers starting with 0. (after an optional sign).

Signature

readonly showNullIntegerPart: boolean

Source

integerPartPadding (property)

If integerPartPadding is a none, no padding is applied. Otherwise the string representation of the integer part of the mantissa will be padded with fillChar’s on the left of the mantissa (but after the sign if there is one) so that it is length characters long (thousandSeparator included).

Formatting: fillChar’s are padded on the left of the mantissa (but after the sign if there is one) until the integer part occupies length characters. Conversion does not fail if the integer part of the mantissa occupies more than length characters (it is displayed as is without any padding).

Parsing: conversion will fail if the string representation of the integer part of the mantissa does not occupy length characters. If it occupies length characters, any fillChar character present on the left of the mantissa (but after the sign if there is one) is removed

Signature

readonly integerPartPadding: Option.Option<{ readonly length: number; readonly fillChar: string; }>

Source

minimumFractionalDigits (property)

Minimum number of digits forming the fractional part of a number. Must be a positive integer (>=0) less than or equal to maximumFractionalDigits. Will not throw otherwise but unexpected results might occur.

Formatting: the string will be right-padded with 0’s if necessary to respect the condition

Parsing: will fail if the input string does not respect this condition (the string must be right-padded with 0’s to respect the condition if necessary).

Signature

readonly minimumFractionalDigits: number

Source

maximumFractionalDigits (property)

Maximum number of digits forming the fractional part of a number. Must be an integer value greater than or equal to minimumFractionalDigits. Will not throw otherwise but unexpected results might occur. Can take the +Infinity value. Use 0 for integers.

Formatting: the number will be rounded using the roundingOption to respect the condition (unless maximumFractionalDigits is +Infinity).

Parsing: will fail if the input string has too many fractional digits.

Signature

readonly maximumFractionalDigits: number

Source

eNotationChars (property)

Possible characters to use to represent e-notation. Usually [‘e’,’E’]. Must be an array of one- character strings. Will not throw otherwise but unexpected results will occur. Not used if scientificNotationOption === None

Formatting: the string at index 0 is used

Parsing: the first character of the e-notation must be one of the one-character strings present in the array

Signature

readonly eNotationChars: ReadonlyArray<string>

Source

scientificNotationOption (property)

Scientific notation options. See ScientificNotationOption

Signature

readonly scientificNotationOption: ScientificNotationOption

Source

roundingOption (property)

Rounding mode options used when formatting. See RoundingOption

Signature

readonly roundingOption: RoundingOption

Source

signDisplayOption (property)

Sign display options. See SignDisplayOption

Signature

readonly signDisplayOption: SignDisplayOption

Source

Modifiers

spacePadded

Returns a copy of self with integerPartPadding set to n and fillChar set to ` `

Signature

declare const spacePadded: MTypes.OneArgFunction<number, MTypes.OneArgFunction<Type, Type>>

Source

withCeilRoundingOption

Returns a copy of self with roundingOption set to Ceil

Signature

declare const withCeilRoundingOption: MTypes.OneArgFunction<Type, Type>

Source

withEngineeringScientificNotation

Returns a copy of self with scientificNotationOption set to Engineering

Signature

declare const withEngineeringScientificNotation: MTypes.OneArgFunction<Type, Type>

Source

withExpandRoundingOption

Returns a copy of self with roundingOption set to Expand

Signature

declare const withExpandRoundingOption: MTypes.OneArgFunction<Type, Type>

Source

withFloorRoundingOption

Returns a copy of self with roundingOption set to Floor

Signature

declare const withFloorRoundingOption: MTypes.OneArgFunction<Type, Type>

Source

withFractionalSeparator

Returns a copy of self with fractionalSeparator set to fractionalSeparator

Signature

declare const withFractionalSeparator: (fractionalSeparator: string) => MTypes.OneArgFunction<Type>

Source

withHalfCeilRoundingOption

Returns a copy of self with roundingOption set to HalfCeil

Signature

declare const withHalfCeilRoundingOption: MTypes.OneArgFunction<Type, Type>

Source

withHalfEvenRoundingOption

Returns a copy of self with roundingOption set to HalfEven

Signature

declare const withHalfEvenRoundingOption: MTypes.OneArgFunction<Type, Type>

Source

withHalfExpandRoundingOption

Returns a copy of self with roundingOption set to HalfExpand

Signature

declare const withHalfExpandRoundingOption: MTypes.OneArgFunction<Type, Type>

Source

withHalfFloorRoundingOption

Returns a copy of self with roundingOption set to HalfFloor

Signature

declare const withHalfFloorRoundingOption: MTypes.OneArgFunction<Type, Type>

Source

withHalfTruncRoundingOption

Returns a copy of self with roundingOption set to HalfTrunc

Signature

declare const withHalfTruncRoundingOption: MTypes.OneArgFunction<Type, Type>

Source

withMaxNDecimals

Returns a copy of self with maximumFractionalDigits set to n. n must be a positive integer (+Infinity allowed). Pass 0 for an integer format

Signature

declare const withMaxNDecimals: (maxDecimalNumber: number) => (self: Type) => Type

Source

withMinNDecimals

Returns a copy of self with minimumFractionalDigits set to n. n must be a finite positive integer

Signature

declare const withMinNDecimals: (minDecimalNumber: number) => (self: Type) => Type

Source

withNDecimals

Returns a copy of self with minimumFractionalDigits and maximumFractionalDigits set to n. n must be a finite positive integer

Signature

declare const withNDecimals: (decimalNumber: number) => MTypes.OneArgFunction<Type>

Source

withNoScientificNotation

Returns a copy of self with scientificNotationOption set to None

Signature

declare const withNoScientificNotation: MTypes.OneArgFunction<Type, Type>

Source

withNormalizedScientificNotation

Returns a copy of self with scientificNotationOption set to Normalized

Signature

declare const withNormalizedScientificNotation: MTypes.OneArgFunction<Type, Type>

Source

withNullIntegerPartNotShowing

Returns a copy of self with showNullIntegerPart set to false

Signature

declare const withNullIntegerPartNotShowing: MTypes.OneArgFunction<Type, Type>

Source

withNullIntegerPartShowing

Returns a copy of self with showNullIntegerPart set to true

Signature

declare const withNullIntegerPartShowing: MTypes.OneArgFunction<Type, Type>

Source

withSignDisplay

Returns a copy of self with signDisplayOption set to Always

Signature

declare const withSignDisplay: MTypes.OneArgFunction<Type, Type>

Source

withSignDisplayExceptZero

Returns a copy of self with signDisplayOption set to ExceptZero

Signature

declare const withSignDisplayExceptZero: MTypes.OneArgFunction<Type, Type>

Source

withSignDisplayForNegative

Returns a copy of self with signDisplayOption set to Auto

Signature

declare const withSignDisplayForNegative: MTypes.OneArgFunction<Type, Type>

Source

withSignDisplayForNegativeExceptZero

Returns a copy of self with signDisplayOption set to Negative

Signature

declare const withSignDisplayForNegativeExceptZero: MTypes.OneArgFunction<Type, Type>

Source

withStandardScientificNotation

Returns a copy of self with scientificNotationOption set to Standard

Signature

declare const withStandardScientificNotation: MTypes.OneArgFunction<Type, Type>

Source

withThousandSeparator

Returns a copy of self with thousandSeparator set to thousandSeparator

Signature

declare const withThousandSeparator: (thousandSeparator: string) => MTypes.OneArgFunction<Type>

Source

withTruncRoundingOption

Returns a copy of self with roundingOption set to Trunc

Signature

declare const withTruncRoundingOption: MTypes.OneArgFunction<Type, Type>

Source

withoutSignDisplay

Returns a copy of self with signDisplayOption set to Never

Signature

declare const withoutSignDisplay: MTypes.OneArgFunction<Type, Type>

Source

withoutThousandSeparator

Returns a copy of self with thousandSeparator set to ‘’

Signature

declare const withoutThousandSeparator: MTypes.OneArgFunction<Type, Type>

Source

zeroPadded

Returns a copy of self with integerPartPadding set to n and fillChar set to 0

Signature

declare const zeroPadded: MTypes.OneArgFunction<number, MTypes.OneArgFunction<Type, Type>>

Source

Module markers

moduleTag

Module tag

Signature

declare const moduleTag: "@parischap/effect-lib/NumberBase10Format/"

Source

Utils

getFixedLength

Returns a some of the length of self if self represents a fixed-length number format. Return a none otherwise

Signature

declare const getFixedLength: (self: Type) => Option.Option<number>

Source