NumberBase10Format overview
This module implements a CVNumberBase10Format which describes the possible options to format/parse a base-10 number or BigDecimal and implements the Formatting/parsing algorithms
Table of contents
- Constructors
- Destructors
- Getters
- Instances
- dutchStyleInteger
- dutchStyleNumber
- dutchStyleUngroupedNumber
- fourDigitSignedInteger
- fourDigitUnsignedInteger
- frenchStyleInteger
- frenchStyleNumber
- frenchStyleUngroupedNumber
- integer
- signedInteger
- threeDigitSignedInteger
- threeDigitUnsignedInteger
- twoDigitSignedInteger
- twoDigitUnsignedInteger
- ukStyleInteger
- ukStyleNumber
- ukStyleUngroupedNumber
- unsignedInteger
- Models
- Type (class)
- make (static method)
- [MData.idSymbol] (method)
- thousandSeparator (property)
- fractionalSeparator (property)
- showNullIntegerPart (property)
- integerPartPadding (property)
- minimumFractionalDigits (property)
- maximumFractionalDigits (property)
- eNotationChars (property)
- scientificNotationOption (property)
- roundingOption (property)
- signDisplayOption (property)
- Type (class)
- Modifiers
- spacePadded
- withCeilRoundingOption
- withEngineeringScientificNotation
- withExpandRoundingOption
- withFloorRoundingOption
- withFractionalSeparator
- withHalfCeilRoundingOption
- withHalfEvenRoundingOption
- withHalfExpandRoundingOption
- withHalfFloorRoundingOption
- withHalfTruncRoundingOption
- withMaxNDecimals
- withMinNDecimals
- withNDecimals
- withNoScientificNotation
- withNormalizedScientificNotation
- withNullIntegerPartNotShowing
- withNullIntegerPartShowing
- withSignDisplay
- withSignDisplayExceptZero
- withSignDisplayForNegative
- withSignDisplayForNegativeExceptZero
- withStandardScientificNotation
- withThousandSeparator
- withTruncRoundingOption
- withoutSignDisplay
- withoutThousandSeparator
- zeroPadded
- Module markers
- Utils
Constructors
make
Constructor
Signature
export declare const make: (params: MTypes.Data<Type>) => Type
Destructors
toDescription
Returns a short description of self, e.g. ‘signed integer’
Signature
export declare const toDescription: (self: Type) => string
Getters
eNotationChars
Returns the eNotationChars property of self
Signature
export declare const eNotationChars: MTypes.OneArgFunction<Type, readonly string[]>
fractionalSeparator
Returns the fractionalSeparator property of self
Signature
export declare const fractionalSeparator: MTypes.OneArgFunction<Type, string>
integerPartPadding
Returns the integerPartPadding property of self
Signature
export declare const integerPartPadding: MTypes.OneArgFunction<
Type,
Option.Option<{ readonly length: number; readonly fillChar: string }>
>
maximumFractionalDigits
Returns the maximumFractionalDigits property of self
Signature
export declare const maximumFractionalDigits: MTypes.OneArgFunction<Type, number>
minimumFractionalDigits
Returns the minimumFractionalDigits property of self
Signature
export declare const minimumFractionalDigits: MTypes.OneArgFunction<Type, number>
roundingOption
Returns the roundingOption property of self
Signature
export declare const roundingOption: MTypes.OneArgFunction<Type, CVRoundingOption.Type>
scientificNotationOption
Returns the scientificNotationOption property of self
Signature
export declare const scientificNotationOption: MTypes.OneArgFunction<
Type,
CVNumberBase10FormatScientificNotationOption.Type
>
showNullIntegerPart
Returns the showNullIntegerPart property of self
Signature
export declare const showNullIntegerPart: MTypes.OneArgFunction<Type, boolean>
signDisplayOption
Returns the signDisplayOption property of self
Signature
export declare const signDisplayOption: MTypes.OneArgFunction<Type, CVNumberBase10FormatSignDisplayOption.Type>
thousandSeparator
Returns the thousandSeparator property of self
Signature
export declare const thousandSeparator: MTypes.OneArgFunction<Type, string>
Instances
dutchStyleInteger
Dutch-style integer CVNumberBase10Format instance. Used in countries like Dutch-speaking Belgium, the Netherlands, Germany, Italy, Norway, Croatia, Spain…
Signature
export declare const dutchStyleInteger: Type
dutchStyleNumber
CVNumberBase10Format 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
export declare const dutchStyleNumber: Type
dutchStyleUngroupedNumber
CVNumberBase10Format 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
export declare const dutchStyleUngroupedNumber: Type
fourDigitSignedInteger
4-digit signed integer CVNumberBase10Format instance with no thousand separator
Signature
export declare const fourDigitSignedInteger: Type
fourDigitUnsignedInteger
4-digit unsigned integer CVNumberBase10Format instance with no thousand separator
Signature
export declare const fourDigitUnsignedInteger: Type
frenchStyleInteger
French-style integer CVNumberBase10Format instance. Used in countries like France, French- speaking Canada, French-speaking Belgium, Denmark, Finland, Sweden…
Signature
export declare const frenchStyleInteger: Type
frenchStyleNumber
CVNumberBase10Format 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
export declare const frenchStyleNumber: Type
frenchStyleUngroupedNumber
CVNumberBase10Format 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
export declare const frenchStyleUngroupedNumber: Type
integer
Integer CVNumberBase10Format instance with no thousand separator
Signature
export declare const integer: Type
signedInteger
SignedInteger CVNumberBase10Format instance with no thousand separator
Signature
export declare const signedInteger: Type
threeDigitSignedInteger
3-digit signed integer CVNumberBase10Format instance with no thousand separator
Signature
export declare const threeDigitSignedInteger: Type
threeDigitUnsignedInteger
3-digit unsigned integer CVNumberBase10Format instance with no thousand separator
Signature
export declare const threeDigitUnsignedInteger: Type
twoDigitSignedInteger
2-digit signed integer CVNumberBase10Format instance with no thousand separator
Signature
export declare const twoDigitSignedInteger: Type
twoDigitUnsignedInteger
2-digit unsigned integer CVNumberBase10Format instance with no thousand separator
Signature
export declare const twoDigitUnsignedInteger: Type
ukStyleInteger
Uk-style integer CVNumberBase10Format instance. Used in countries like the UK, the US, English- speaking Canada, Australia, Thaïland, Bosnia…
Signature
export declare const ukStyleInteger: Type
ukStyleNumber
CVNumberBase10Format 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
export declare const ukStyleNumber: Type
ukStyleUngroupedNumber
CVNumberBase10Format 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
export declare const ukStyleUngroupedNumber: Type
unsignedInteger
Unsigned integer CVNumberBase10Format instance with no thousand separator
Signature
export declare const unsignedInteger: Type
Models
Type (class)
Type that represents a CVNumberBase10Format
Signature
export declare class Type {
private constructor({
thousandSeparator,
fractionalSeparator,
showNullIntegerPart,
integerPartPadding,
minimumFractionalDigits,
maximumFractionalDigits,
eNotationChars,
scientificNotationOption,
roundingOption,
signDisplayOption
}: MTypes.Data<Type>)
}
make (static method)
Static constructor
Signature
static make(params: MTypes.Data<Type>): Type
[MData.idSymbol] (method)
Returns the id of this
Signature
[MData.idSymbol](): string | (() => string)
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
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
showNullIntegerPart (property)
Formatting:
- If
true, numbers with a null integer part are displayed starting with0. Otherwise, they are displayed starting with.unlessmaximumFractionalDigits===0, in which case they are displayed starting with0.
Parsing
- If
true, conversion will fail for numbers starting with.(after an optional sign). - If
false, conversion will fail for numbers starting with0.(after an optional sign).
Signature
readonly showNullIntegerPart: boolean
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; }>
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
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
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: readonly string[]
scientificNotationOption (property)
Scientific notation options. See CVNumberBase10FormatScientificNotationOption
Signature
readonly scientificNotationOption: CVNumberBase10FormatScientificNotationOption.Type
roundingOption (property)
Rounding mode options used when formatting. See CVRoundingOption.ts
Signature
readonly roundingOption: CVRoundingOption.Type
signDisplayOption (property)
Sign display options. See CVNumberBase10FormatSignDisplayOption.ts
Signature
readonly signDisplayOption: CVNumberBase10FormatSignDisplayOption.Type
Modifiers
spacePadded
Returns a copy of self with integerPartPadding set to n and fillChar set to ` `
Signature
export declare const spacePadded: MTypes.OneArgFunction<number, MTypes.OneArgFunction<Type, Type>>
withCeilRoundingOption
Returns a copy of self with roundingOption set to Ceil
Signature
export declare const withCeilRoundingOption: MTypes.OneArgFunction<Type, Type>
withEngineeringScientificNotation
Returns a copy of self with scientificNotationOption set to Engineering
Signature
export declare const withEngineeringScientificNotation: MTypes.OneArgFunction<Type, Type>
withExpandRoundingOption
Returns a copy of self with roundingOption set to Expand
Signature
export declare const withExpandRoundingOption: MTypes.OneArgFunction<Type, Type>
withFloorRoundingOption
Returns a copy of self with roundingOption set to Floor
Signature
export declare const withFloorRoundingOption: MTypes.OneArgFunction<Type, Type>
withFractionalSeparator
Returns a copy of self with fractionalSeparator set to fractionalSeparator
Signature
export declare const withFractionalSeparator: (fractionalSeparator: string) => MTypes.OneArgFunction<Type>
withHalfCeilRoundingOption
Returns a copy of self with roundingOption set to HalfCeil
Signature
export declare const withHalfCeilRoundingOption: MTypes.OneArgFunction<Type, Type>
withHalfEvenRoundingOption
Returns a copy of self with roundingOption set to HalfEven
Signature
export declare const withHalfEvenRoundingOption: MTypes.OneArgFunction<Type, Type>
withHalfExpandRoundingOption
Returns a copy of self with roundingOption set to HalfExpand
Signature
export declare const withHalfExpandRoundingOption: MTypes.OneArgFunction<Type, Type>
withHalfFloorRoundingOption
Returns a copy of self with roundingOption set to HalfFloor
Signature
export declare const withHalfFloorRoundingOption: MTypes.OneArgFunction<Type, Type>
withHalfTruncRoundingOption
Returns a copy of self with roundingOption set to HalfTrunc
Signature
export declare const withHalfTruncRoundingOption: MTypes.OneArgFunction<Type, Type>
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
export declare const withMaxNDecimals: (maxDecimalNumber: number) => (self: Type) => Type
withMinNDecimals
Returns a copy of self with minimumFractionalDigits set to n. n must be a finite positive integer
Signature
export declare const withMinNDecimals: (minDecimalNumber: number) => (self: Type) => Type
withNDecimals
Returns a copy of self with minimumFractionalDigits and maximumFractionalDigits set to n. n must be a finite positive integer
Signature
export declare const withNDecimals: (decimalNumber: number) => MTypes.OneArgFunction<Type>
withNoScientificNotation
Returns a copy of self with scientificNotationOption set to None
Signature
export declare const withNoScientificNotation: MTypes.OneArgFunction<Type, Type>
withNormalizedScientificNotation
Returns a copy of self with scientificNotationOption set to Normalized
Signature
export declare const withNormalizedScientificNotation: MTypes.OneArgFunction<Type, Type>
withNullIntegerPartNotShowing
Returns a copy of self with showNullIntegerPart set to false
Signature
export declare const withNullIntegerPartNotShowing: MTypes.OneArgFunction<Type, Type>
withNullIntegerPartShowing
Returns a copy of self with showNullIntegerPart set to true
Signature
export declare const withNullIntegerPartShowing: MTypes.OneArgFunction<Type, Type>
withSignDisplay
Returns a copy of self with signDisplayOption set to Always
Signature
export declare const withSignDisplay: MTypes.OneArgFunction<Type, Type>
withSignDisplayExceptZero
Returns a copy of self with signDisplayOption set to ExceptZero
Signature
export declare const withSignDisplayExceptZero: MTypes.OneArgFunction<Type, Type>
withSignDisplayForNegative
Returns a copy of self with signDisplayOption set to Auto
Signature
export declare const withSignDisplayForNegative: MTypes.OneArgFunction<Type, Type>
withSignDisplayForNegativeExceptZero
Returns a copy of self with signDisplayOption set to Negative
Signature
export declare const withSignDisplayForNegativeExceptZero: MTypes.OneArgFunction<Type, Type>
withStandardScientificNotation
Returns a copy of self with scientificNotationOption set to Standard
Signature
export declare const withStandardScientificNotation: MTypes.OneArgFunction<Type, Type>
withThousandSeparator
Returns a copy of self with thousandSeparator set to thousandSeparator
Signature
export declare const withThousandSeparator: (thousandSeparator: string) => MTypes.OneArgFunction<Type>
withTruncRoundingOption
Returns a copy of self with roundingOption set to Trunc
Signature
export declare const withTruncRoundingOption: MTypes.OneArgFunction<Type, Type>
withoutSignDisplay
Returns a copy of self with signDisplayOption set to Never
Signature
export declare const withoutSignDisplay: MTypes.OneArgFunction<Type, Type>
withoutThousandSeparator
Returns a copy of self with thousandSeparator set to ‘’
Signature
export declare const withoutThousandSeparator: MTypes.OneArgFunction<Type, Type>
zeroPadded
Returns a copy of self with integerPartPadding set to n and fillChar set to 0
Signature
export declare const zeroPadded: MTypes.OneArgFunction<number, MTypes.OneArgFunction<Type, Type>>
Module markers
moduleTag
Module tag
Signature
export declare const moduleTag: "@parischap/conversions/formatting/NumberBase10Format/"
Utils
getFixedLength
Returns a some of the length of self if self represents a fixed-length number format. Return a none otherwise
Signature
export declare const getFixedLength: (self: Type) => Option.Option<number>