Passed
Push — main ( 5cacf5...da0f78 )
by Pedro
02:28
created

src/format/part.ts

Complexity

Total Complexity 0
Complexity/F 0

Size

Lines of Code 33
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 33
ccs 5
cts 5
cp 1
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
/*
2
 * decimal.js-i18n v0.2.6
3
 * Full internationalization support for decimal.js.
4
 * MIT License
5
 * Copyright (c) 2022 Pedro José Batista <[email protected]>
6
 * https://github.com/pjbatista/decimal.js-i18n
7
 */
8
import type FormatPartTypes from "./partTypes";
9
10
// Filters:
11 1
export const decimals = <T extends PartType>({ type }: T) => type === "decimal";
12 82723
export const exponents = <T extends PartType>({ type: t }: T) => t === "exponentInteger" || t === "exponentMinusSign";
13 82723
export const fractions = <T extends PartType>({ type }: T) => type === "fraction";
14 83084
export const integerGroups = <T extends PartType>({ type }: T) => type === "integer" || type === "group";
15 61984
export const integers = <T extends PartType>({ type }: T) => type === "integer";
16
17
/** Object used to describe a single transliteration part of `Decimal.Format.formatToParts`. */
18
export type FormatPart = PartType & PartValue;
19
20
/** Fragment of a part containing the type. */
21
export interface PartType {
22
    /** A string describing the formatting part. */
23
    type: Intl.NumberFormatPartTypes | FormatPartTypes;
24
}
25
26
/** Fragment of a part containing the value. */
27
export interface PartValue {
28
    /** Localized string with a fragment of the result. */
29
    value: string;
30
}
31
32
export default FormatPart;
33