Total Complexity | 0 |
Complexity/F | 0 |
Lines of Code | 30 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 100% |
Changes | 0 |
1 | /*! |
||
2 | * Copyright (c) 2022 Pedro José Batista, licensed under the MIT License. |
||
3 | * See the LICENSE.md file in the project root for more information. |
||
4 | */ |
||
5 | import type FormatPartTypes from "./partTypes"; |
||
6 | |||
7 | // Filters: |
||
8 | 1 | export const decimals = <T extends PartType>({ type }: T) => type === "decimal"; |
|
9 | 15078 | export const exponents = <T extends PartType>({ type: t }: T) => t === "exponentInteger" || t === "exponentMinusSign"; |
|
10 | 15078 | export const fractions = <T extends PartType>({ type }: T) => type === "fraction"; |
|
11 | 15439 | export const integerGroups = <T extends PartType>({ type }: T) => type === "integer" || type === "group"; |
|
12 | 14378 | export const integers = <T extends PartType>({ type }: T) => type === "integer"; |
|
13 | |||
14 | /** Object used to describe a single transliteration part of `Decimal.Format.formatToParts`. */ |
||
15 | export type FormatPart = PartType & PartValue; |
||
16 | |||
17 | /** Fragment of a part containing the type. */ |
||
18 | export interface PartType { |
||
19 | /** A string describing the formatting part. */ |
||
20 | type: Intl.NumberFormatPartTypes | FormatPartTypes; |
||
21 | } |
||
22 | |||
23 | /** Fragment of a part containing the value. */ |
||
24 | export interface PartValue { |
||
25 | /** Localized string with a fragment of the result. */ |
||
26 | value: string; |
||
27 | } |
||
28 | |||
29 | export default FormatPart; |
||
30 |