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

NumberBase10Formatter overview

This module implements a CVNumberBase10Formatter, i.e. an object that can convert a number into a string according to the CVNumberBase10Format that was used to construct it


Table of contents


Constructors

fromFormat

Constructor of a CVNumberBase10Formatter from a CVNumberBase10Format

Signature

export declare const fromFormat: (format: CVNumberBase10Format.Type) => Type

Getters

description

Returns the description property of self

Signature

export declare const description: MTypes.OneArgFunction<Type, string>

format

Returns the format property of self.

Signature

export declare const format: MTypes.OneArgFunction<Type, MTypes.OneArgFunction<number | BigDecimal.BigDecimal, string>>

Models

Type (class)

Type that represents a CVNumberBase10Formatter

Signature

export declare class Type {
  constructor(numberFormat: CVNumberBase10Format.Type)
}

[MData.idSymbol] (method)

Returns the id of this

Signature

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

description (property)

Description of this formatter, e.g. ‘signed integer formatter’

Signature

readonly description: string

format (property)

Function that formats a number respecting the options represented by the CVNumberBase10Format from which this was constructed. If successful, that function returns a some of the formatted number. Otherwise, it returns a none. number can be of type number or BigDecimal for better accuracy. There is a difference between number and BigDecimal (and bigint) regarding the sign of 0. In Javascript, Object.is(0,-0) is false whereas Object.is(0n,- 0n) is true. So if the sign of zero is important to you, prefer passing a number to the function. 0 as a BigDecimal will always be interpreted as a positive 0 as we have no means of knowing if it is negative or positive

Signature

readonly format: MTypes.OneArgFunction<number | BigDecimal.BigDecimal, string>

Module markers

moduleTag

Module tag

Signature

export declare const moduleTag: "@parischap/conversions/formatting/NumberBase10Format/NumberBase10Formatter/"