src/format/part.ts
last analyzed

Complexity

Total Complexity 0
Complexity/F 0

Size

Lines of Code 30
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 0
eloc 18
mnd 0
bc 0
fnc 0
dl 0
loc 30
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
ccs 5
cts 5
cp 1
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