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
- Destructors
- Getters
- Instances
- dutchStyleInteger
- dutchStyleNumber
- dutchStyleUngroupedNumber
- fourDigitSignedInteger
- fourDigitUnsignedInteger
- frenchStyleInteger
- frenchStyleNumber
- frenchStyleUngroupedNumber
- integer
- signedInteger
- threeDigitSignedInteger
- threeDigitUnsignedInteger
- twoDigitSignedInteger
- twoDigitUnsignedInteger
- ukStyleInteger
- ukStyleNumber
- ukStyleUngroupedNumber
- unsignedInteger
- Models
- BigDecimalExtraction (interface)
- 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)
- 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
declare const make: (params: MTypes.Data<Type>) => Type
Destructors
toDescription
Returns a short description of self, e.g. ‘signed integer’
Signature
declare const toDescription: (self: Type) => string
Getters
eNotationChars
Returns the eNotationChars property of self
Signature
declare const eNotationChars: MTypes.OneArgFunction<Type, ReadonlyArray<string>>
fractionalSeparator
Returns the fractionalSeparator property of self
Signature
declare const fractionalSeparator: MTypes.OneArgFunction<Type, string>
integerPartPadding
Returns the integerPartPadding property of self
Signature
declare const integerPartPadding: MTypes.OneArgFunction<
Type,
Option.Option<{ readonly length: number; readonly fillChar: string }>
>
maximumFractionalDigits
Returns the maximumFractionalDigits property of self
Signature
declare const maximumFractionalDigits: MTypes.OneArgFunction<Type, number>
minimumFractionalDigits
Returns the minimumFractionalDigits property of self
Signature
declare const minimumFractionalDigits: MTypes.OneArgFunction<Type, number>
roundingOption
Returns the roundingOption property of self
Signature
declare const roundingOption: MTypes.OneArgFunction<Type, RoundingOption>
scientificNotationOption
Returns the scientificNotationOption property of self
Signature
declare const scientificNotationOption: MTypes.OneArgFunction<Type, ScientificNotationOption>
showNullIntegerPart
Returns the showNullIntegerPart property of self
Signature
declare const showNullIntegerPart: MTypes.OneArgFunction<Type, boolean>
signDisplayOption
Returns the signDisplayOption property of self
Signature
declare const signDisplayOption: MTypes.OneArgFunction<Type, SignDisplayOption>
thousandSeparator
Returns the thousandSeparator property of self
Signature
declare const thousandSeparator: MTypes.OneArgFunction<Type, string>
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
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
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
fourDigitSignedInteger
4-digit signed integer MNumberBase10Format instance with no thousand separator
Signature
declare const fourDigitSignedInteger: Type
fourDigitUnsignedInteger
4-digit unsigned integer MNumberBase10Format instance with no thousand separator
Signature
declare const fourDigitUnsignedInteger: Type
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
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
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
integer
Integer MNumberBase10Format instance with no thousand separator
Signature
declare const integer: Type
signedInteger
SignedInteger MNumberBase10Format instance with no thousand separator
Signature
declare const signedInteger: Type
threeDigitSignedInteger
3-digit signed integer MNumberBase10Format instance with no thousand separator
Signature
declare const threeDigitSignedInteger: Type
threeDigitUnsignedInteger
3-digit unsigned integer MNumberBase10Format instance with no thousand separator
Signature
declare const threeDigitUnsignedInteger: Type
twoDigitSignedInteger
2-digit signed integer MNumberBase10Format instance with no thousand separator
Signature
declare const twoDigitSignedInteger: Type
twoDigitUnsignedInteger
2-digit unsigned integer MNumberBase10Format instance with no thousand separator
Signature
declare const twoDigitUnsignedInteger: Type
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
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
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
unsignedInteger
Unsigned integer MNumberBase10Format instance with no thousand separator
Signature
declare const unsignedInteger: Type
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
}
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>)
}
make (static method)
Static constructor
Signature
declare const make: (params: MTypes.Data<Type>) => Type
[MData.idSymbol] (method)
Returns the id of this
Signature
declare const [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: ReadonlyArray<string>
scientificNotationOption (property)
Scientific notation options. See ScientificNotationOption
Signature
readonly scientificNotationOption: ScientificNotationOption
roundingOption (property)
Rounding mode options used when formatting. See RoundingOption
Signature
readonly roundingOption: RoundingOption
signDisplayOption (property)
Sign display options. See SignDisplayOption
Signature
readonly signDisplayOption: SignDisplayOption
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>>
withCeilRoundingOption
Returns a copy of self with roundingOption set to Ceil
Signature
declare const withCeilRoundingOption: MTypes.OneArgFunction<Type, Type>
withEngineeringScientificNotation
Returns a copy of self with scientificNotationOption set to Engineering
Signature
declare const withEngineeringScientificNotation: MTypes.OneArgFunction<Type, Type>
withExpandRoundingOption
Returns a copy of self with roundingOption set to Expand
Signature
declare const withExpandRoundingOption: MTypes.OneArgFunction<Type, Type>
withFloorRoundingOption
Returns a copy of self with roundingOption set to Floor
Signature
declare const withFloorRoundingOption: MTypes.OneArgFunction<Type, Type>
withFractionalSeparator
Returns a copy of self with fractionalSeparator set to fractionalSeparator
Signature
declare const withFractionalSeparator: (fractionalSeparator: string) => MTypes.OneArgFunction<Type>
withHalfCeilRoundingOption
Returns a copy of self with roundingOption set to HalfCeil
Signature
declare const withHalfCeilRoundingOption: MTypes.OneArgFunction<Type, Type>
withHalfEvenRoundingOption
Returns a copy of self with roundingOption set to HalfEven
Signature
declare const withHalfEvenRoundingOption: MTypes.OneArgFunction<Type, Type>
withHalfExpandRoundingOption
Returns a copy of self with roundingOption set to HalfExpand
Signature
declare const withHalfExpandRoundingOption: MTypes.OneArgFunction<Type, Type>
withHalfFloorRoundingOption
Returns a copy of self with roundingOption set to HalfFloor
Signature
declare const withHalfFloorRoundingOption: MTypes.OneArgFunction<Type, Type>
withHalfTruncRoundingOption
Returns a copy of self with roundingOption set to HalfTrunc
Signature
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
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
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
declare const withNDecimals: (decimalNumber: number) => MTypes.OneArgFunction<Type>
withNoScientificNotation
Returns a copy of self with scientificNotationOption set to None
Signature
declare const withNoScientificNotation: MTypes.OneArgFunction<Type, Type>
withNormalizedScientificNotation
Returns a copy of self with scientificNotationOption set to Normalized
Signature
declare const withNormalizedScientificNotation: MTypes.OneArgFunction<Type, Type>
withNullIntegerPartNotShowing
Returns a copy of self with showNullIntegerPart set to false
Signature
declare const withNullIntegerPartNotShowing: MTypes.OneArgFunction<Type, Type>
withNullIntegerPartShowing
Returns a copy of self with showNullIntegerPart set to true
Signature
declare const withNullIntegerPartShowing: MTypes.OneArgFunction<Type, Type>
withSignDisplay
Returns a copy of self with signDisplayOption set to Always
Signature
declare const withSignDisplay: MTypes.OneArgFunction<Type, Type>
withSignDisplayExceptZero
Returns a copy of self with signDisplayOption set to ExceptZero
Signature
declare const withSignDisplayExceptZero: MTypes.OneArgFunction<Type, Type>
withSignDisplayForNegative
Returns a copy of self with signDisplayOption set to Auto
Signature
declare const withSignDisplayForNegative: MTypes.OneArgFunction<Type, Type>
withSignDisplayForNegativeExceptZero
Returns a copy of self with signDisplayOption set to Negative
Signature
declare const withSignDisplayForNegativeExceptZero: MTypes.OneArgFunction<Type, Type>
withStandardScientificNotation
Returns a copy of self with scientificNotationOption set to Standard
Signature
declare const withStandardScientificNotation: MTypes.OneArgFunction<Type, Type>
withThousandSeparator
Returns a copy of self with thousandSeparator set to thousandSeparator
Signature
declare const withThousandSeparator: (thousandSeparator: string) => MTypes.OneArgFunction<Type>
withTruncRoundingOption
Returns a copy of self with roundingOption set to Trunc
Signature
declare const withTruncRoundingOption: MTypes.OneArgFunction<Type, Type>
withoutSignDisplay
Returns a copy of self with signDisplayOption set to Never
Signature
declare const withoutSignDisplay: MTypes.OneArgFunction<Type, Type>
withoutThousandSeparator
Returns a copy of self with thousandSeparator set to ‘’
Signature
declare const withoutThousandSeparator: MTypes.OneArgFunction<Type, Type>
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>>
Module markers
moduleTag
Module tag
Signature
declare const moduleTag: "@parischap/effect-lib/NumberBase10Format/"
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>